how to solve this

1 次查看(过去 30 天)
daniel
daniel 2022-12-25

回答(1 个)

John D'Errico
John D'Errico 2022-12-25
You already solved it. So where is the problem? If I had to guess, it is why the circle you just plotted does not appear circular. For that, you need to learn why it is that you use
axis equal
Which forces the x and y axes to have the same spacing.
Or, maybe why it is that the variables x and y you defined before the call to ezplot have nothing to do with the plot you show, so no impact. That is because ezplot does not use workspace variables.
But maybe your question is something completely different.
  2 个评论
daniel
daniel 2022-12-25
How do I change the ranges of x and y according to the image
John D'Errico
John D'Errico 2022-12-25
You probably want to use xlim and ylim. For example, I'll use ezplot, since you did already. (fimplicit or fplot are better (newer) tools though.)
ezplot('x.^2 +x.*y + y.^2 - 3')
By default, ezplot decided to use axes that go to [-6,+6] on each axis. You can change that in several ways.
For example, let me redo the plot, but this time, I'll use xlim and ylim.
ezplot('x.^2 +x.*y + y.^2 - 3')
xlim([-4,4])
ylim([-3,3])
Or, you can use handle graphics calls to modify the plot.
ezplot('x.^2 +x.*y + y.^2 - 3')
The axis handle allows you to change any of those axis properties after the plot was created. It is found by a call to gca.
gca
ans =
Axes ({x}^{2} +{x} {y} + {y}^{2} - {3} = {0}) with properties: XLim: [-6.2832 6.2832] YLim: [-6.2832 6.2832] XScale: 'linear' YScale: 'linear' GridLineStyle: '-' Position: [0.1300 0.1100 0.7750 0.8150] Units: 'normalized' Show all properties
And now we can modify any of those properties.
set(gca,'XLim',[-5,5],'YLim',[-5,5])

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by