MATLAB graphics drawing-set coordinate scale

Set coordinate scale

We can use axiscommands to set the drawing range. The general commands are as follows:

aixs([xmin xmax ymin ymax])

Suppose we want to produce an image with a function y = sin(2x+3)in 0~5between, and ythe values we consider are between -1 and 1, then we can set yto display only these values:

>> x = [0:0.01:5];
>> y = sin(2*x + 3);
>> plot(x,y),axis([0 5 -1 1])

axis range
Now let's draw. New function
Try it first xin the range of 0 to 5, yin the range of -1 to 1:

>> x = [0:0.01:5];
>> y = exp(-1.5*x).*sin(5*x+3);
>> plot(x,y,'k'),axis([0 5 -1 1])

The image is as follows:
axis black

As you can see from the figure, ythe range can be adjusted again.
We try to yadjust the range to -0.7 ~ 0.3, so the axiscommand is changed to the following form:

>> plot(x,y,'k'),axis([0 5 -0.7 0.3])

axis narrowing
The image now looks more compact.
Below we draw function
the MATLABcorrect way to square the function in is to use array multiplication, that is, dot product:
Power of function
for example:

>> y = sin(5*x).^2;

We use black dotted lines to draw:

>> x = [0:0.01:1];
>> y = sin(5*x).^2;
>> plot(x,y,'k:'),axis([0 1 0 1])

The picture is as follows:
axis black dotted linexfunction image between 0 ~ 5:
Extended range image
review:

  • axis equal Coordinate axes are equally spaced
  • axis square Produces a square image

axis equal

Published 84 original articles · won 18 · views 5805

Guess you like

Origin blog.csdn.net/qq_44486550/article/details/105208386