for loop / an array as an output from for loop

4 visualizaciones (últimos 30 días)
Aleksandra Ksiezyk
Aleksandra Ksiezyk el 25 de Ag. de 2020
Comentada: Aleksandra Ksiezyk el 25 de Ag. de 2020
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

Respuesta aceptada

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

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by