Array indices must be positive integers or logical values. Error

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: if it helped please remember to click the accept button.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2024년 2월 14일

댓글:

2024년 2월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by