Import .mat files and arrange some data in a matrix

1 Ansicht (letzte 30 Tage)
Sina Kafshi
Sina Kafshi am 10 Jun. 2019
Beantwortet: Sina Kafshi am 11 Jun. 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 Kommentare
Sulaymon Eshkabilov
Sulaymon Eshkabilov am 10 Jun. 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 am 10 Jun. 2019
Yes, they are all datas from a .mat file.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Weitere Antworten (1)

Sina Kafshi
Sina Kafshi am 11 Jun. 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

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by