Automatisation of .mat files load and storing into a matrix

1 visualización (últimos 30 días)
Haythem Zouabi
Haythem Zouabi el 26 de Oct. de 2020
Comentada: Haythem Zouabi el 11 de Nov. de 2020
Hello,
I have different .mat files named as dx001, dx002,... dx0020.
I want to automate the .mat files load and storing it into a vector of matrix:
dataArray={}
for i=1:20
temp=load(['dx00' num2str(i) '.mat'])
dataArray{i} = ['temp.dx00' num2str(i) '.mat'];
end
This line ( dataArray{i} = ['temp.dx00' num2str(i) '.mat']; ) shows an error:
Do you have any recommandations?
Thanks,

Respuestas (1)

Stephen23
Stephen23 el 26 de Oct. de 2020
Editada: Stephen23 el 26 de Oct. de 2020
N = 20;
C = cell(1,N);
for k = 1:N
F = sprintf('dx00%d.mat',k);
S = load(F);
C(k) = struct2cell(S); % if there is only one variable in the file
% or
%C{k} = S.(sprintf('dx00%d',k));
end
  7 comentarios
Stephen23
Stephen23 el 28 de Oct. de 2020
"My question is..."
That is quite a different topic to this thread. You should post that as a new question.
Haythem Zouabi
Haythem Zouabi el 11 de Nov. de 2020
Hello,
I want to display the NaN values by setting an alphadata equal to 0 and at the same time apply an alphadata equal to 0.3 for values different to NaNs?
This is the code i use but it doesn't work:
im=imagesc(I,'AlphaData',~isnan(I))
set(im,'AlphaData',0.3);
Thanks,

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by