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

4 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by