how can i solve it

2 次查看(过去 30 天)
Ls
Ls 2021-8-18
评论: Rik 2021-8-22
i=1:100;
vx_1(i)=(X1(i)-X1((i)-1))/(t(i)-t((i)-1)); % In general
vx_1(1)= (X1(1)-X1(N-1))/(t(N)-t(N-1)); % for i=1
I get the error: Array indices must be positive integers or logical values.
How can I solve it
it works well when you put i= single digit but does not work for array? eg it works well when i=6

采纳的回答

Walter Roberson
Walter Roberson 2021-8-18
When i is 1 then i-1 is 0, and you would be referring to X1(0) and t(0) .
MATLAB cannot use index 0.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by