MATLAB: Command asking to repeat previous step

matrix manipulation

[EDIT: 20110728 14:37 CDT – reformat – WDR]
Hello.. my question is: How to write programming code asking to return to the previous step i.e if A=B; we hv to return to step 2 (do all over again starting from step 2). my code is
for s = 1:23
d{s,1} = b{s,1}*(b{s,1})';
A{s,1} = eig(d{s,1}); %Find the eigenvalues
anyNegativeA = any(A(:)<0); %thanks to 'the cyclist' for the code..
if anyNegativeA; %checking if there's any entries in -ve value.
B = A*2;
end
end
…and now, what's the command asking to repeat the 'find the eigenvalues' step

Best Answer

If A=B then because B=A*2, it must be the case that A=A*2 . That can only be true if every entry in A is one of (0, infinity, -infinity, or NaN). Note though that if that is the case, the only one of those that is negative for the anyNegative test is -infinity, so the B=A*2 test would only be invoked if at least one of the eigenvalues comes out as -infinity.
After you change B, that does not feed back to changing anything that is used do calculate the eigenvalues. The eigenvalues are determined entirely based upon the cell array "b" indexed at "s", but you have not changed "b" or "s". Going back and recalculating the eigenvalues would give you the same result, so you would infinite loop.
I think you need to reconsider your logic.