how to solve this

1 view (last 30 days)
daniel
daniel on 25 Dec 2022
Commented: John D'Errico on 25 Dec 2022

Answers (1)

John D'Errico
John D'Errico on 25 Dec 2022
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 Comments
daniel
daniel on 25 Dec 2022
How do I change the ranges of x and y according to the image
John D'Errico
John D'Errico on 25 Dec 2022
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])

Sign in to comment.

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Tags

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!