for loop / an array as an output from for loop

4 ビュー (過去 30 日間)
Aleksandra Ksiezyk
Aleksandra Ksiezyk 2020 年 8 月 25 日
コメント済み: Aleksandra Ksiezyk 2020 年 8 月 25 日
please can anyone help me with my problem, this is a bit too difficult for me and i do not know how to solve it... so
I have arrays:
A = [1 2017 1 1 1]' ;
B = [2 2017 1 1 1]' ;
C = [1 2005 1 1 1]' ;
Simulation = [A B C] ;
So my matrix looks like:
Simulation =
1 2 1
2017 2017 2005
1 1 1
1 1 1
1 1 1
How can i create a loop function (or any other idea) that i would do the simulation where:
for Sim_1 i would take variables from the first column of Simulation matrix and have variables
D = 1
E = 2017
F = 1
G = 1
H = 1 (basicly those are an A array)
for Sim_2 i would take varibles from the secon column of Simulation matrix and get :
D = 2
E = 2017
F = 1
G = 1
H = 1 (array B)
and so on
any hint, tip i would appriciate

採用された回答

Matt J
Matt J 2020 年 8 月 25 日
編集済み: Matt J 2020 年 8 月 25 日
Sim = num2cell(Simulation);
for i=1:size(Sim,2)
[D,E,F,G,H]=deal(Sim{:,i})
%other stuff...
end
  1 件のコメント
Aleksandra Ksiezyk
Aleksandra Ksiezyk 2020 年 8 月 25 日
thank you so much and for such a quick answer !

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by