フィルターのクリア

saving Iterations in the loop below

2 ビュー (過去 30 日間)
TTA
TTA 2016 年 8 月 24 日
コメント済み: Andrei Bobrov 2016 年 8 月 24 日
Somebody please help urgently. I want to save the values of iterations of Modata in the loop. The current code is not working.
Ro = 0.05:0.1:0.45;
ii = 20*pi/180:20*pi/180:90*pi/180;
BGammaMax = 0.5:0.1:3;
phi2 = 0:2*pi/60:2*pi;
L = [];
for Ro_s = Ro
for ii_s = ii
for bg_s = BGammaMax
for phi2_s = phi2;
L2 =sqrt( Ro_s*ii_s)+(bg_s*phi2_s);
L = [L;L2];
MoData = [Ro_s ii_s bg_s phi2_s L2]
FN = (num2str(Ro_s), num2str(ii_s), num2str(bg_s), num2str(phi2), num2str(L));
dlmwrite('myFile.txt',FN,'delimiter',' ');
end
end
end
end
  1 件のコメント
Andrei Bobrov
Andrei Bobrov 2016 年 8 月 24 日
It's repeat.

サインインしてコメントする。

採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 8 月 24 日
編集済み: Andrei Bobrov 2016 年 8 月 24 日
Ro = 0.05:0.1:0.45;
ii = 20*pi/180:20*pi/180:90*pi/180;
BGammaMax = 0.5:0.1:3;
phi2 = 0:2*pi/60:2*pi;
a = cell(1,4);
[a{end:-1:1}] = ndgrid(phi2,BGammaMax,ii,Ro);
z = cell2mat(cellfun(@(x)x(:),a,'un',0));
MoData = [z, sqrt(z(:,1).*z(:,2)), z(:,3).*z(:,4)];
or
[x4,x3,x2,x1] = ndgrid(phi2,BGammaMax,ii,Ro);
MoData = [x1(:),x2(:),x3(:),x4(1), sqrt(x1(:).*x2(:)), x3(:).*x4(:)];
  4 件のコメント
Andrei Bobrov
Andrei Bobrov 2016 年 8 月 24 日
編集済み: Andrei Bobrov 2016 年 8 月 24 日
[x4,x3,x2,x1] = ndgrid(phi2,BGammaMax,ii,Ro);
L = arrayfun(@(a,b,c,d)RoT(a,b,c,d),x1(:),x2(:),x3(:),x4(:));
MoData = [x1(:),x2(:),x3(:),x4(:),L];
Andrei Bobrov
Andrei Bobrov 2016 年 8 月 24 日
Please show RoT.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by