I keep getting an error message for my subplot syntax? Could anyone out there look over my script, and tell me whats wrong?

조회 수: 9 (최근 30일)
%subplot.m x = 0:0.1:5; y = exp(-1.2*x).*sin(10*x+5); subplot(1,2,1) plot(x,y),xlabel('x'), ylabel('y'),axis([0 5 -1 11]) x = -6:0.1:6; y = abs(x.^3-100); subplot(1,2,2) plot(x,y),xlabel ('x'),ylabel('y'),axis([-6 6 0 350])
  댓글 수: 3
Carlyle Hickman
Carlyle Hickman 2016년 10월 26일
Attempt to execute SCRIPT subplot as a function: E:\subplot.m
Error in subplot (line 4) subplot(1,2,1)
Chaya N
Chaya N 2016년 10월 26일
Right! Please change the name of the script to something else so it doesn't override the inbuilt function and you're good to go.

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

채택된 답변

Chaya N
Chaya N 2016년 10월 26일
This is simply a reformatted version. Please try running this:
x = 0:0.1:5;
y = exp(-1.2*x).*sin(10*x+5);
subplot(1,2,1), plot(x,y);
xlabel('x'), ylabel('y'),axis([0 5 -1 11]);
x = -6:0.1:6;
y = abs(x.^3-100);
subplot(1,2,2), plot(x,y);
xlabel ('x'),ylabel('y'),axis([-6 6 0 350]);

추가 답변 (1개)

Changoleon
Changoleon 2016년 10월 26일
Hey, try putting semicolon (;) between your commands instead of comma (,)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by