Set coordinate scale
We can use axis
commands 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~5
between, and y
the values we consider are between -1 and 1, then we can set y
to display only these values:
>> x = [0:0.01:5];
>> y = sin(2*x + 3);
>> plot(x,y),axis([0 5 -1 1])
Now let's draw.
Try it first x
in the range of 0 to 5, y
in 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:
As you can see from the figure, y
the range can be adjusted again.
We try to y
adjust the range to -0.7 ~ 0.3, so the axis
command is changed to the following form:
>> plot(x,y,'k'),axis([0 5 -0.7 0.3])
The image now looks more compact.
Below we draw
the MATLAB
correct way to square the function in is to use array multiplication, that is, dot product:
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:
x
function image between 0 ~ 5:
review:
axis equal
Coordinate axes are equally spacedaxis square
Produces a square image