필터 지우기
필터 지우기

Plotting 3 graphs in the same figure

조회 수: 3 (최근 30일)
Anastasia Kyriakou
Anastasia Kyriakou 2020년 2월 26일
댓글: Image Analyst 2020년 3월 9일
Write a programme to plot the function f(x)=xsin(pi(9x+1)) over the interval [−1, 1] using increments in x of (a) 0.2, (b) 0.1, and (c) 0.01. The programme should plot the three graphs in the same figure. Include the legend to specify which graph corresponds to which increment. (Observe that the plots for cases (a) and (b) givetotally the wrong picture of ݂f(x)).
Could someone help me?
x = linspace(0.2:0.1:0.01);
y = x*sin(pi*(9*x+1));
y=[-1:1]
figure
plot(x,y)
  댓글 수: 3
darova
darova 2020년 2월 26일
Yes. I found some mistakes
Image Analyst
Image Analyst 2020년 3월 9일
Anastasia: Did David's solution below work for you? If so, please Accept it.

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

채택된 답변

David Hill
David Hill 2020년 2월 26일
z=@(x)x.*sin(pi*(9*x+1));
x={-1:.2:1,-1:.1:1,-1:.01:1};
y=cellfun(@(k)z(k),x,'UniformOutput',false);
plot(x{1},y{1},x{2},y{2},x{3},y{3});

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by