Reputation: 4742
Is it possible to somehow to have two outcomes from each IF
and ELSEIF
. My example is as follows,
so at the moment my code is:
for i=1:(size(y,2))
if maxind(i) == maxy
y(:,i) = y(:,i)*100;
elseif maxind(i) <= maxy/40
y(:,i) = y(:,i)*40;
end
end
However I would like to record the multiplication coefficients corresponding to each y(:,i)
.
I would like to do something like this below with my hypothetical code in " ":
for i=1:(size(y,2))
if maxind(i) == maxy
y(:,i) = y(:,i)*100 "& coeficient(i) = 100";
elseif maxind(i) <= maxy/40
y(:,i) = y(:,i)*40 "& coeficient(i) = 100";
end
end
I cant simply repeat this FOR
after as the y(:,i)
's change, I could do it before but it seems a little messy. Thanks in advance.
Upvotes: 1
Views: 65
Reputation: 35525
Why not?:
for i=1:(size(y,2))
if maxind(i) == maxy
y(:,i) = y(:,i)*100
coeficient(i) = 100;
% you can add here as many lines you want...
elseif maxind(i) <= maxy/40
y(:,i) = y(:,i)*40
coeficient(i) = 40;
% here also, thats the WHOLE pourpose of the "end"
end
end
Upvotes: 3