フィルターのクリア

ylim error "Array indices must be positive integers or logical values"

39 ビュー (過去 30 日間)
Em
Em 2022 年 1 月 13 日
コメント済み: Em 2022 年 1 月 14 日
Hi everyone,
When I try to set the y axis limits using the code below, I get an error message. Please could someone suggest why this is happening? The code works totally fine without the ylim instruction.
figure
subplot(4,2,8);
plot(powerpc,abs(depth50mms_09),powerpc,abs(depth60mms_09),powerpc,abs(depth70mms_09),powerpc,abs(depth80mms_09),powerpc,abs(depth90mms_09),powerpc,abs(depth100mms_09))
ylabel('Track Depth/um');
xlabel({'Laser Power/mW';'DR = 0.9'})
M=7;
% pick some colormap and apply it to the colororder property
mycolortable = parula(M);
ylim([0 5])
set(gca,'colororder',mycolortable)
Error message:
Array indices must be positive integers or logical values.
Error in depthprogABSvaluesdiscarded (line 12)
ylim([0 5])
Cheers

採用された回答

Voss
Voss 2022 年 1 月 13 日
You have a variable called ylim, so the instruction ylim([0 5]) means to get the elements in ylim at index 0 and index 5, which is in error since indexes start at 1 in MATLAB. Do clear('ylim') to clear the variable so that the built-in function ylim() will run instead, or do clear all at the top of your script.
  1 件のコメント
Em
Em 2022 年 1 月 14 日
Thanks so much! This solution worked.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by