Matlab Array indixing error
古いコメントを表示
Hi,
On Matlab 2022 i have the following error :
Array indices must be positive integers or logical values.
Error in mdl2List>NomBarreMdl (line 1022)
y1=Nom(end-1:end);
I don't know why it gives me this error because when i use the debugger and i pause on the same line and i use this line on the matlab command it works perfectly. But in the function it doesn't.
5 件のコメント
Dyuman Joshi
2022 年 11 月 18 日
編集済み: Dyuman Joshi
2022 年 11 月 18 日
What is the type of variable Nom and how many elements does it have?
Also, since the error occurs while running the code as a part of the function, I would suggest you to show the function code as well.
Nom = [1,2]; % two elements
Nom(end-1:end)
Nom = 3; % one element
Nom(end-1:end)
Have a look at the size of the array and the indices you are requesting.
Ali
2022 年 11 月 18 日
Stephen23
2022 年 11 月 18 日
"so i don't understand why"
Your function assumes that NOM has two or more elements, but does not check this in any way. This is a bug.
Ali
2022 年 11 月 18 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!