필터 지우기
필터 지우기

for loop / an array as an output from for loop

조회 수: 1 (최근 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 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