Fullfile code gives error in other system
2 views (last 30 days)
Show older comments
Hello Every one,
I have written the following code and it works well (reading some mat files from a folder, loading them and lator I do some calculations on the data),
V_deficit=dir('Vel_defcit_data/*.mat');
for i=1:27
def_path = fullfile(V_deficit(i).folder,V_deficit(i).name);
load(def_path)
end
but the problem is that when I send this exact code to someone else it doesnt work, we get the error:
Reference to non-existent field 'folder'.
Error in Vel_deficit
def_path = fullfile(V_deficit(i).folder,V_deficit(i).name);
I also asked to change the folder names to Vel_deficit as here, but still we get the error!
Thank you in advance for your help
0 Comments
Accepted Answer
Stephen23
on 9 Aug 2023
Your "someone else" is using a MATLAB version older than R2016b:
so the FOLDER field does not exist. Instead you can refer to the folder you specify:
P = 'Vel_defcit_data';
S = dir(fullfile(P,'*.mat'));
for k = 1:numel(S)
F = fullfile(P,S(k).name);
T = load(F)
% do whatever with T
end
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!