Hello everyone,
I have a plot what starts at one instead of zero.
Can someone tell me were my fail is?
B=app.BEditField.Value;
C=app.CEditField.Value;
D=app.DEditField.Value;
E=app.EEditField.Value;
x = linspace(0,pi,100);
y=D*sin(C*atan(B*x-E*(B*x-atan(B*x))));
plot(app.UIAxes,y);
app.UIAxes.YLim = [-0.2 (D+0.2)];
app.UIAxes.XLim = [-10 100];

답변 (1개)

Stephane Dauvillier
Stephane Dauvillier 2022년 9월 19일

0 개 추천

Hi you should use x and y in the plot command:
plot(app.UIAxes,x,y)

댓글 수: 4

Benedikt Schumacher
Benedikt Schumacher 2022년 9월 19일
Hi if I plot it with X the course of the course isn't right. If I plot without x the course is the right one, but only starts at 1. I attached you the pictures. Thank you for your help.
Voss
Voss 2022년 9월 19일
Try plotting with x and y and setting the XLim appropriately:
x = linspace(0,pi,100);
y=D*sin(C*atan(B*x-E*(B*x-atan(B*x))));
plot(app.UIAxes,x,y);
app.UIAxes.YLim = [-0.2 (D+0.2)];
app.UIAxes.XLim = [0 pi];
Steven Lord
Steven Lord 2022년 9월 19일
That is correct. For an explanation, from the Description section on the plot documentation page:
"plot(Y) plots Y against an implicit set of x-coordinates.
  • If Y is a vector, the x-coordinates range from 1 to length(Y).
  • If Y is a matrix, the plot contains one line for each column in Y. The x-coordinates range from 1 to the number of rows in Y."
In this case, app.UIAxes is not X data (which would cause MATLAB to use the plot(x, y) syntax.) It is recognized as an axes so the first syntax in Additional Options is used, then the remaining input is interpreted as Y data using the syntax above.
your plot with x is the right one.The limits of the axes are not what you want but the data are well drawed.
ANd you can use the function below to set the limit of axes
xlim(app.UIAxes,[-10,100])
ylim(app.UIAxes,[-0.2,0.2+D])

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

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

릴리스

R2022a

질문:

2022년 9월 19일

댓글:

2022년 9월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by