command asking to repeat previous step
显示 更早的评论
[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
采纳的回答
更多回答(2 个)
the cyclist
2011-7-28
0 个投票
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 个评论
Nur Najiha
2011-7-28
the cyclist
2011-7-28
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
2012-4-29
0 个投票
@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.
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!