i am getting error in the plot function it says array indices must be +ve int or logical value
이전 댓글 표시
v1(1)=2;
v2(1)=4;
v3(1)=-1;
for n = 1:50
a1(n)=v1(n)-v2(n);
v1(n+1)=v1(n)+a1(n)*0.1;
a2(n)=v3(n)-3;
v2(n+1)=v2(n)+a2(n)*0.1;
a3(n)=a1(n)-a2(n);
v3(n+1)=v3(n)+a3(n)*0.1;
end
t= 0:0.1:5;
plot(t,v1(t*10+1))
hold all
plot(t,v2(t*10+1))
plot(t,v3(t*10+1))
댓글 수: 1
Why you want tp index v with t? you need not to do it while plotting.
The error is due to indexing. Array indices should be posititive integers in MATLAB. If you use ractions, you will get error.
A = rand(1,3) ;
A(0.5) % error
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
