x=Xout t=x(:,1); plot(t,x(:,2),'c') 'index exceeds matrix dimension' is what this line will always display. help me with the solution. thanks

댓글 수: 1

It would be much neater code if you formatted it so that it was not all on one line, as it seems to be now. And there is no need to create new variables just for plotting. Try something like this:
plot(Xout(:,1),Xout(:,2),'c')
Of course this still does not solve your problem that Xout does not have enough columns to plot...

댓글을 달려면 로그인하십시오.

 채택된 답변

Stephen23
Stephen23 2015년 1월 20일
편집: Stephen23 2015년 1월 20일

0 개 추천

Have a look at the size of x in your workspace. Or type size(x) where you are running this code.
How many columns does x have?
You will find that it either has no columns, or only one column, and so your indexing (:,1) or x(:,2) is trying to extract data from a column that simply does not exist, thus the error.
You can now go back through your code, and find out why ithas fewer columns that you think it should. Perhaps there is a bug in your code, or some missing data...

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

질문:

2015년 1월 20일

댓글:

2015년 1월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by