Borrar filtros
Borrar filtros

Fullfile code gives error in other system

3 visualizaciones (últimos 30 días)
mehra
mehra el 9 de Ag. de 2023
Respondida: Stephen23 el 9 de Ag. de 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

Respuesta aceptada

Stephen23
Stephen23 el 9 de Ag. de 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

Más respuestas (0)

Categorías

Más información sobre File Name Construction en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by