Fullfile code gives error in other system

2 次查看(过去 30 天)
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

采纳的回答

Stephen23
Stephen23 2023-8-9
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 个)

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by