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

4 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Walter Roberson
Walter Roberson il 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.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by