Getting an error message and don't know how to fix
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
the cyclist
2019-11-21
编辑:the cyclist
2019-11-21
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?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!