Import .mat files and arrange some data in a matrix

조회 수: 1 (최근 30일)
Sina Kafshi
Sina Kafshi 2019년 6월 10일
답변: Sina Kafshi 2019년 6월 11일
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
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019년 6월 10일
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 2019년 6월 10일
Yes, they are all datas from a .mat file.

댓글을 달려면 로그인하십시오.

채택된 답변

per isakson
per isakson 2019년 6월 11일
Set Pause on Errors and run again
Capture.PNG

추가 답변 (1개)

Sina Kafshi
Sina Kafshi 2019년 6월 11일
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

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by