Execution of code ends prematurely

4 ビュー (過去 30 日間)
Kyle
Kyle 2011 年 3 月 12 日
Hi,
I have a function that is about 100 lines long, but it is not executed after the following block within the function:
k = 1;
coeffs=[];
[m_cutfit2, n_cutfit2] = size(co_c_s_f);
while k <= n_cutfit2
coeffs = vertcat(coeffs, polyfit(q_fitting,co_c_s_f(:,k),9));
k=k+1;
end
%rest of code
No error message or busy signal is given. What is the general cause of this problem, and how may I fix it in this case?
Thanks

採用された回答

Kyle
Kyle 2011 年 3 月 12 日
@Matt - Thanks for the cleaning up of the concatenation code. I wasn't sure how to do that.
When I cleared all variables and re-ran the script, it worked. Sorry to have wasted your time. I appreciate your help though.

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 3 月 12 日
If the second dimension of co_c_s_f is 0 (empty matrix) then the loop will not be executed because 1 <= 0 is false.
If you are saying that the loop is being executed but somewhere along the way the routine as a whole quits, then have you try commanding
dbstop if error
at the command line, before execution?

Matt Tearle
Matt Tearle 2011 年 3 月 12 日
This isn't the cause of the problem, but first:
n_cutfit2 = size(co...,2);
coeffs = zeros(n_cutfit2,10)
for k = 1:n_cutfit2
coeffs(k,:) = ...
end
Now, do you mean that the code executes up to and including this loop, but the rest of the code just doesn't run? How have you determined this? Have you tried setting a breakpoint at the next line? Without seeing the rest of the code, it's hard to know what might be happening.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by