command asking to repeat previous step
Ältere Kommentare anzeigen
[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
1 Kommentar
Nur Najiha
am 28 Jul. 2011
Akzeptierte Antwort
Weitere Antworten (2)
the cyclist
am 28 Jul. 2011
0 Stimmen
Nur, the things you are asking are very basic MATLAB questions, or really even just very basic programming questions. This is not really a very good place to learn basic programming. I suggest, if you want to learn the basics of MATLAB, to thoroughly digest this:
2 Kommentare
Nur Najiha
am 28 Jul. 2011
the cyclist
am 28 Jul. 2011
My guess is that you actually will want to use a "while" loop structure, which typically better for situations where you want to check whether a certain condition is true, then run the loop again depending on the result.
Nathaniel Ewing
am 29 Apr. 2012
0 Stimmen
@the cyclist
Unfortunately this is what's happening in engineering schools right now. I'm currently a mechanical engineering student, and what they've done to the curriculum is basically throw you into an engineering lab without knowing any matlab or even basic programming. It's a big shock and it's hard to learn Matlab while trying to get a good grade in a lab. Fortunately they're starting to restructure so next year's freshman will be taking all beginning programming their freshman year as well.
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!