Fullfile code gives error in other system
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
mehra
am 9 Aug. 2023
Beantwortet: Stephen23
am 9 Aug. 2023
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 Kommentare
Akzeptierte Antwort
Stephen23
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!