Import .mat files and arrange some data in a matrix

1 view (last 30 days)
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 Comments
Sulaymon Eshkabilov
Sulaymon Eshkabilov on 10 Jun 2019
In your code, all_frac_am variable is not defined. Maybe you have its values already available in your matlab workspace?

Sign in to comment.

Accepted Answer

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

More Answers (1)

Sina Kafshi
Sina Kafshi on 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

Categories

Find more on Cell Arrays in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!