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 Center および File ExchangeCell Arrays についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by