Making a for loop

3 次查看(过去 30 天)
MadjeKoe
MadjeKoe 2020-12-13
评论: MadjeKoe 2020-12-13
Hi guys,
I want to put the last 4 sentences into a for loop, can someone please explain to me how to do this?? I've been reading a lot about them but I just don't know how to make them work.
OrientationGabor1 = res(:,9);
OrientationGabor2 = res(:,8);
OrientationGabor3 = res(:,7);
OrientationGabor4 = res(:,6);
Targets = res(:,1);
Responses = res(:,2);
ResponseError = res(:,3);
TargetOrientationGabor1 = OrientationGabor1(Targets==1);
TargetOrientationGabor2 = OrientationGabor2(Targets==2);
TargetOrientationGabor3 = OrientationGabor3(Targets==3);
TargetOrientationGabor4 = OrientationGabor4(Targets==4);

采纳的回答

Walter Roberson
Walter Roberson 2020-12-13
It isn't a good idea. You are better off using cell arrays,
OrientationGabor = res(:,[9 8 7 6]);
TargetOrientationGabor = cell(4,1);
for T = 1 : 4
TargetOrientationGabor{T} = OrientationGabor(Targets == 1, T);
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