Getting an error message and don't know how to fix
10 views (last 30 days)
Show older comments
Holly Martin
on 21 Nov 2019
Commented: Holly Martin
on 21 Nov 2019
I have code that looks like this
% The loop
for i=1:N-1
v=diff(z);
v(i+1) = v(i) + h*(((-g-k*(abs(v)).^p)*V)/m);
z(i+1) = z(i)+h*v(i+1);
end
the error message has come up like this in the command window
Error in particle (line 24)
v(i+1) = v(i) + h*(((-g-k*(abs(v)).^p)*V)/m);
No idea what ive done, its probably a really easy fix but im having a blonde moment. New to this stuff. Thanks :)
2 Comments
Accepted Answer
the cyclist
on 21 Nov 2019
Edited: the cyclist
on 21 Nov 2019
abs(v)
is a vector, so the right-hand side is a vector. You are trying to put that into one element of v on the left-hand side.
Maybe you meant
abs(v(i))
there?
More Answers (0)
See Also
Categories
Find more on Logical 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!