Unable to perform assignment because the left and right sides have a different number of elements.

1 vue (au cours des 30 derniers jours)
I'm getting the error in the title and not sure how to fix it. My code is below:
%% Analytical Solution
% Plot the theoretical 'x' and 'y' displacments of projectile to compare to
% finite difference method.
for i = 1:Niter %(From 1 to total number of iterations)
tSim(i) = (i-1)*dt;
tNow(i) = tSim(i);
Ax(i) = vx0*tNow;
Ay(i) = (-0.5*g*(tNow)^2) + (vy0*tNow) + y0;
end
Thankyou

Réponses (1)

Rik
Rik le 23 Mai 2020
tNow is a vector, so you can't store it in a scalar, which is what you are trying to do. You probably want to replace every instance of tNow with tNow(i), or replace the entire loop with array operations.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by