loop内のテーブル書き込み
4 views (last 30 days)
Show older comments
各被験者(合計20人)の下に以下のようなファイルがあります。AとBは違う領域です。一つずつのmat.fileにMという変数があります。Mは1行8列のデータになります(8列ですが、1列目と5列目、2列目と6列目、...が同じ条件、2列の平均は1条件の値になります)。
一つ一つのmat.fileのM値に基づき、条件ごとの平均値を列のデータとして、人数分行のテーブルに書き込みたいです(即ち20行、4例のテーブル)。データの右側に心理的指標のデータ(demo.xlsx: 20行3列のファイル)を加えたものを.xlsx fileに書き込みたいです。
stir ='F:\AOA';
subject={001 002};
vois={A...
B};
r1=[6 6 9 9];
r2=[6 9 6 9];
thrname={'005','001','0001'};
load demo;
for s=1:length(subject)
for v=1:length(vois)
for th=1:length(thrname)
for r=1:length(r1)
for m=1:length(r2)
load ([stir filesep subject{s} vois{v} '_r' num2str(r1(r)) '_m' num2str(r2(m)) '_thr' thrname(th) '_beta.mat']);
N =[ (M(:,1)+M(:,5))/2, (M(:,2)+M(:,6))/2, (M(:,3)+M(:,7))/2, (M(:,4)+M(:,8))/2];
Q= [N demo]
end
end
end
end
end
loop内のテーブルの書き込み方よく出ていていないです。教えていただければ幸いです。
2 Comments
Shunichi Kusano
on 12 Aug 2020
全て把握できていませんが、少なくともloadの部分、thrname(th)ですとセルが出力されてしまうため、他の部分(文字列)と整合せずにエラーになると思います。始めから小数点は抜いた形でthrnameを作るのが簡単かなと思います。
thrname = {'005','001','0001'};
thrname{1} % ans = '005'
Answers (0)
See Also
Categories
Find more on スプレッドシート 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!