??? In an assignment A(I) = B, the number of elements in B and I must be the same.
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Walter Roberson
el 27 de Mzo. de 2013
Perhaps
y(:,i+1) = (1/6)*(k_1+2*k_2+2*k_3+k_4)*h;
instead of the assignment you have.
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!