Say I am running a regression in MATLAB and I want to use a for loop to say first do it for y1 and second do it for y2. Is this possible.
I am trying to think of a minimal example, the only this I can come up with to display what I am trying to do is here:
for ii = 1:10
yt = z(ii);
end
Obviously it not running as I am far away from the right logic here , but basically I want to do something in MATLAB for y1 and then so again for y2 and y3 and so on. y1, y2 etc are arrays.
Is there any for loop I can use for zz(ii) to get z1 z2 z3.....
I'll provide a simple example. Suppose you have a matrix A
with an unknown amount of columns and rows and you want to iterate through all of them.
for i=1:length(A(:,1))
for j=1:length(A(1,:))
yt = A(i,j);
% And what ever you want to do
end
end
This way you can access each element individually.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.