Import .mat files and arrange some data in a matrix

1 visualización (últimos 30 días)
Sina Kafshi
Sina Kafshi el 10 de Jun. de 2019
Respondida: Sina Kafshi el 11 de Jun. de 2019
files2import= dir('*.mat');
frac_am= cell(1,length(files2import)); % initiation cell array for each needed value
frac_cbm= cell(1,length(files2import));
cond_El_eff= cell(1,length(files2import));
cond_Ionic_eff= cell(1,length(files2import));
aS_eff= cell(1,length(files2import));
numVal= 5; % need variables from 3D simulation(here: frac_am,frac_cbm,cond_El_eff,cond_Ionic_eff,aS_eff)
for filei=1:length(files2import)
load(files2import(filei).name); % load datas from .mat files in workplace
frac_am{filei}= all_frac_am; % acquire datas from each test and put them in a cell
frac_cbm{filei}= all_frac_cbm;
cond_El_eff{filei}= cond_El_eff_stack;
cond_Ionic_eff{filei}= cond_Ionic_eff_stack;
aS_eff{filei}= aS_eff_stack;
if filei==1 %initiation of matrix containing datas from all tests
alldataM= zeros(length(files2import),numSamples,numVal);
end
alldataM(filei,1,:)= all_frac_am;
alldataM(filei,2,:)= all_frac_cbm;
alldataM(filei,3,:)= cond_El_eff_stack;
alldataM(filei,4,:)= cond_Ionic_eff_stack;
alldataM(filei,4,:)= aS_eff_stack;
end
So this is my code but I get always this error: "Cell contents assignment to a non-cell array object." all values are in size 1*numSamples. I need them organized so I can use them in some graphs.
  2 comentarios
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 10 de Jun. de 2019
In your code, all_frac_am variable is not defined. Maybe you have its values already available in your matlab workspace?
Sina Kafshi
Sina Kafshi el 10 de Jun. de 2019
Yes, they are all datas from a .mat file.

Iniciar sesión para comentar.

Respuesta aceptada

per isakson
per isakson el 11 de Jun. de 2019
Set Pause on Errors and run again
Capture.PNG

Más respuestas (1)

Sina Kafshi
Sina Kafshi el 11 de Jun. de 2019
yes, it pauses on "cond_Ionic_eff{filei}= cond_Ionic_eff_stack;" but cond_Ionic_eff_stack is just like other variables of size 1*10

Categorías

Más información sobre Cell Arrays en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by