当前位置:网站首页>Day (5) of picking up matlab

Day (5) of picking up matlab

2022-04-23 15:59:00 Sola_ Ex

Matlab

Two dimensional curve drawing

plot() function

plot(x,y)			%x Abscissa ,y Vertical coordinates 
ploy(y)				% Serial number as abscissa ,y As ordinate 
plot(x,y,s)			%s Output style representation 

Common graphic decoration commands
 Insert picture description here

Graphics window segmentation

subplot(m,n,p)				% Divide the current window into m*n A drawing area ,p For serial number 

Such as :

subplot(2,2,1)
subplot(2,2,2)
subplot(2,2,3)
subplot(2,2,4)

Linear Cartesian graph

The drawing commands are as follows :

bar(x,y,s)				% Bar chart 
stairs(x,y,s)			% Stairs 
stem(x,y,s)				% Bar graph 
fill(x,y,s)				% Fill in the picture 

The example code uses :

x=0:0.4:8;
y = 2*exp(-0.5*x);

subplot(2,2,1);
bar(x,y,'r');
title('bar(x,y,"red")');
axis([-2,8.1,-1,2.1]);

subplot(2,2,2);
bar(x,y,'g');
title('bar(x,y,"green")');
axis([-2,8.1,-1,2.1]);
...

Logarithmic plot

Application scenarios :

  • When the variable changes by an order of magnitude in the scope of the study
  • When the dependent variable changes a little
  • When the curve part needs to be divided into expanded form
  • When it is necessary to transform a nonlinear relationship into a linear relationship

There are :

semilogx(x,y,s)			% Semilogarithmic coordinates ,x The axis is a logarithmic scale 
semilogy(x,y,s)			% Semilogarithmic coordinates ,y The axis is a logarithmic scale 
loglog(x,y,s)					% Semilogarithmic coordinates ,x,y The axis is logarithmic scale 

Case use

x=1:1e4;
y=20*log10(x.^2-x.^3);
plot(x,y)
figure;   % Create a new picture 
semilogx(x,y,'r');

The effect is as shown in the picture :
 Insert picture description here

Polar diagram

polar(theta,rho,s)			%theta =  Polar coordinates and polar angles ,rho= Polar diameter 

The sample code :

t=0:.01:2*pi;
r1=cos(9*t);
polar(t,r1,'-m')
title(' to CK Rose thread ')

 Insert picture description here
I think it's still very good-looking. Ha ha ha !!!

版权声明
本文为[Sola_ Ex]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231554164100.html