error message 'The end operator must be used within an array index expression.'

12 ビュー (過去 30 日間)
Em
Em 2021 年 9 月 30 日
コメント済み: Walter Roberson 2025 年 7 月 4 日
Hi,
When I try to plot
plot(H20Vs{1:end,1},H20Vs{1:end,2})
hold on
plot(M20Vs{1:end,1},M20Vs{1:end,2})
hold on
plot(N20Vlin{1:end,1},N20Vlin{1:end,2})
% hold on
% plot(P20Vs{1:end,1},P20Vs{1:end,2})
legend('a' ,'b', 'c', 'd', 'e', 'f', 'h', 'l', 'm', 'n')
I recieve this error message 'The end operator must be used within an array index expression.'
Does anyone have any idea why this could be happening? I noticed the last two plot functions don't cause this issue, only the first one.
Cheers

回答 (1 件)

Walter Roberson
Walter Roberson 2025 年 7 月 4 日
It is likely that the error is in code before what was posted. For example,
a(end)=1
The end operator must be used within an array index expression.
This error occurs because end was used to index an array that does not exist yet.
  3 件のコメント
Stephen23
Stephen23 2025 年 7 月 4 日
H20Vs might be a table, in which case that syntax does not generate a comma-separated list.
Walter Roberson
Walter Roberson 2025 年 7 月 4 日
Good point about tables.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by