for loop / an array as an output from for loop

4 views (last 30 days)
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

Accepted Answer

Matt J
Matt J on 25 Aug 2020
Edited: Matt J on 25 Aug 2020
Sim = num2cell(Simulation);
for i=1:size(Sim,2)
[D,E,F,G,H]=deal(Sim{:,i})
%other stuff...
end

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!