??? In an assignment A(I) = B, the number of elements in B and I must be the same.

4 ビュー (過去 30 日間)
Nicholas
Nicholas 2013 年 3 月 27 日
I am solving rungekutta equation of order K_4. However I am getting the above error at the final part when I want to conclude the main equation. See the code;
dm = @(t_1,r)Tau.*M_T'.*Free_area'.*v./(D_p.*t_1);
for i=1:(length(x)-1) % calculation loop
k_1 = dm(x(i),y(i));
k_2 = dm(x(i)+0.5*h,y(i)+0.5*h*k_1);
k_3 = dm((x(i)+0.5*h),(y(i)+0.5*h*k_2));
k_4 = dm((x(i)+h),(y(i)+k_3*h));
y(i+1) = (1/6)*(k_1+2*k_2+2*k_3+k_4)*h; % main equation
end
I can get only one vector of the right side of the equation but I need an array . I know my problem is to do with the left side of the main equation as I didn't locate enough space for the output array but how can I do it? any help?

採用された回答

Walter Roberson
Walter Roberson 2013 年 3 月 27 日
Perhaps
y(:,i+1) = (1/6)*(k_1+2*k_2+2*k_3+k_4)*h;
instead of the assignment you have.

その他の回答 (0 件)

カテゴリ

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