Error with using vector(end) to get last index number
이전 댓글 표시
I have the following line of code:
if temp_small_time(end) ~= temp_large_time(end)
It's producing an error that says Subscript indices must either be real positive integers or logicals. I just want to know if the value at the end of each vector is the same, but I don't "know" where the end is, thus, I'm using the end keyword. What is wrong here?
댓글 수: 3
louis rassinfosse
2016년 4월 29일
You can know where the end is by using "length(X)" (if 1 line/column or "size(X)" if it is an MxN matrix ..
Jadee Kellogg
2016년 4월 29일
louis rassinfosse
2016년 4월 29일
What does your matrixes look like? Could you add the code?
답변 (3개)
Star Strider
2016년 4월 29일
0 개 추천
Sometimes an error will occur pointing to a line that is not actually where the error occurred. Check the line just before it to see if there’s some sort of problem with that line.
댓글 수: 2
Jadee Kellogg
2016년 4월 29일
Star Strider
2016년 4월 29일
Since it’s an if block, it would be best to post the entire if block, since the problem would likely occur only if the particular statement was executed.
Seeing the code could give a clue.
Walter Roberson
2016년 4월 29일
0 개 추천
It sounds like you assigned a value to a variable named "end"
댓글 수: 3
Jadee Kellogg
2016년 4월 29일
Star Strider
2016년 4월 29일
I did that experiment (assigning a variable to ‘end’). MATLAB has serious problems with that, and throws an assignment error.
Walter Roberson
2016년 4월 29일
Your array is empty. Accessing an empty array at (end) results in that error message.
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!