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

Asked by David Wiebe

### David Wiebe (view profile)

on 21 Jan 2019
Latest activity Edited by per isakson

### per isakson (view profile)

on 21 Jan 2019
function [t,v]= Partc ( m,c,g,t0,v0,tn,n )
fprintf('values of t approximations v(t)\n')
fprintf('%8.3f',t0)
fprintf('%19.4f\n',v0)
h=(tn-t0)/n;
t=[t0:h:tn];
v=zeros(1, n);
v(1)=v0;
for i=1:n
v(i+1)=v(i)+(g*m/c)*(1-exp(-c*t/m)));
fprintf('%8.3f',t(i+1));
fprintf('%19.4f\n',v(i+1));
end
plot(t,v)
end
Line 10: (( v(i+1)=v(i)+(g*m/c)*(1-exp(-c*t/m))); keeps giving me the "Unable to perform assignment because the left and right sides have a different number of elements" error. Any help would be appreciated.

### per isakson (view profile)

Answer by per isakson

### per isakson (view profile)

on 21 Jan 2019
Edited by per isakson

### per isakson (view profile)

on 21 Jan 2019

Maybe replace
v(i+1)=v(i)+(g*m/c)*(1-exp(-c*t/m)));
by
v(i+1)=v(i)+(g*m/c)*(1-exp(-c*t(i)/m)));
v(i+1) is a scalar, I assume, thus the rhs should be a scalar.
Does that make sense?