??? In an assignment A(I) = B, the number of elements in B and I must be the same.
4 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
Walter Roberson
on 27 Mar 2013
Perhaps
y(:,i+1) = (1/6)*(k_1+2*k_2+2*k_3+k_4)*h;
instead of the assignment you have.
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!