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.
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++;
}
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
whileloop if it works?whileoffers no built in control over a loop variable, which you obvioulsy need, so why not leave it as a for loop instead of having to code the loop variable handling yourself?