Reputation: 9
In C++ for
loop is same as while
loop
for(int i=0; i<10; i++)
{
}
int j;
while(j<10)
{
cout<<" ";
j++;
}
I want to convert this for
loop in while
loop using MATLAB.
Upvotes: 1
Views: 378
Reputation: 526
i = 2;
while i <= zoom_r -1
j = 2;
while j<= zoom_c -1
... executable code block goes here
j = j+1;
end
i = i+1;
end
Upvotes: 1
Reputation: 1552
The loops are not exactly the same as you actually... Still, I don't know matlab, but since you posted a C++ example I will assume you will be able to convert this to matlab, if it helps.
int i, j;
i = j = 2;
while(...) {//i condition
while(...) { //j condition
<...commands...>
j++:
}
j = 2; //reset inner while counter to w/e value you need
i++;
}
Upvotes: 2