Array indices must be positive integers or logical values. Error

1 回表示 (過去 30 日間)
Grégoire
Grégoire 2024 年 2 月 14 日
コメント済み: Stephen23 2024 年 2 月 14 日
Hey I m trying to plot these 2 functions, but when runing it it tells me : "Array indices must be positive integers or logical values." my workspace is empty.
I would be happy to learn what is going wrong...
Thanks
clear
x1= -2:0,01:2;
f1 = x1.^2-1;
f2 = sin(x1);
h1 = plot(x1,f1(x1),'b',x1,f2(x1),'r').grid;

採用された回答

Stephen23
Stephen23 2024 年 2 月 14 日
編集済み: Stephen23 2024 年 2 月 14 日
x1= -2:0.01:2; % decimal comma -> point
f1 = x1.^2-1;
f2 = sin(x1);
h1 = plot(x1,f1,'b',x1,f2,'r') % removed superfluous indexing
h1 =
2×1 Line array: Line Line
  2 件のコメント
Grégoire
Grégoire 2024 年 2 月 14 日
Thanks !
Stephen23
Stephen23 2024 年 2 月 14 日
@Grégoire: if it helped please remember to click the accept button.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by