Fullfile code gives error in other system
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Stephen23
le 9 Août 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!