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

1 view (last 30 days)
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

Answers (1)

Rik
Rik on 23 May 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.

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!