for loop / an array as an output from for loop

1 次查看(过去 30 天)
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by