フィルターのクリア

Error: subscript indices must either be real positive integers or logicals.

3 ビュー (過去 30 日間)
Sergey Kasyanov
Sergey Kasyanov 2017 年 3 月 1 日
コメント済み: Sergey Kasyanov 2017 年 3 月 1 日
Hello,
this part of function doesn't working and I don't have any idea why.
hA=axes;
hold on
for i=1:length(Data)
hL(i)=plot(hA,Data(i).x,Data(i).y);
set(hL(i),'LineWidth',LW{i});
end
If I type this code in command window it work perfectly. If I use it as part of function it return:
Subscript indices must either be real positive integers or logicals.
Error in plotGraph (line 144)
set(hL(i),'LineWidth',LW{i});
  1 件のコメント
Adam
Adam 2017 年 3 月 1 日
Use
dbstop if error
and look at what 'i' is on the line in question.

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

採用された回答

Jan
Jan 2017 年 3 月 1 日
編集済み: Jan 2017 年 3 月 1 日
It seems like you have created a variable called "set". Then the arguments are treated as indices and the string causes the error:
set = rand(100, 100, 3)
set(hL(i), 'LineWidth', LW{i});
% ^ Bad index!
The solution is easy: Do not use "set" as name of a variable.
To check if this is the problem, let Matlab stop, when the error occurs: Type this in the command window and run your code again:
dbstop if error
Now check:
which set -all
I guess, the topmost result is a local variable, and not Matlab's built-in function.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by