matlab - grÁficos

4
GRÁFICOS NO MATLAB Plotando gráficos y=(-5:0.1:4).^3; plot(y) length(y) Gráfico com grade e título x =-5:0.1:4; y=(x).^3; plot(x,y) xlabel('x'); ylabel('y'); title('graph of y = x^3'); grid; Várias funções sobrepostas x1=0:.1:10; y1=cos(x1); x2=1.5*x1; y2=2*cos(x2); >> x3=2*x1; >> y3=3*sin(x3); >> plot(x1,y1,x2,y2,x3,y3) Linha tracejada vermelha x =-5:0.1:4; y=(x).^3; plot(x,y) >> plot(x,y,'--r'); Linha amarela x =-5:0.1:4; y=(x).^3; plot(x,y) >> plot(x,y,'--y'); Linha com bolinhas y=(x).^3; plot(x,y) plot(x,y,'--y'); >> plot(x,y,'--o'); Simple 2D plot Manipulation Three plot statements x=-2:.1:2; plot(x,sin(x),'-x'); hold on plot(x,sin(x.^2),'--b'); plot(x,cos(x.^2),':g'); hold off

Upload: sandro-cordeiro-sao-marcos

Post on 09-Apr-2016

14 views

Category:

Documents


1 download

DESCRIPTION

Gráficos em MATLAB.

TRANSCRIPT

Page 1: MATLAB - GRÁFICOS

GRÁFICOS NO MATLAB

Plotando gráficos

y=(-5:0.1:4).^3;

plot(y)

length(y)

Gráfico com grade e título

x =-5:0.1:4;

y=(x).^3;

plot(x,y)

xlabel('x');

ylabel('y');

title('graph of y = x^3');

grid;

Várias funções sobrepostas

x1=0:.1:10;

y1=cos(x1);

x2=1.5*x1;

y2=2*cos(x2);

>> x3=2*x1;

>> y3=3*sin(x3);

>> plot(x1,y1,x2,y2,x3,y3)

Linha tracejada vermelha

x =-5:0.1:4;

y=(x).^3;

plot(x,y)

>> plot(x,y,'--r');

Linha amarela

x =-5:0.1:4;

y=(x).^3;

plot(x,y)

>> plot(x,y,'--y');

Linha com bolinhas

y=(x).^3;

plot(x,y)

plot(x,y,'--y');

>> plot(x,y,'--o');

Simple 2D plot Manipulation

Three plot statements

x=-2:.1:2;

plot(x,sin(x),'-x');

hold on

plot(x,sin(x.^2),'--b');

plot(x,cos(x.^2),':g');

hold off

Page 2: MATLAB - GRÁFICOS

Autoscaling

x1=0:.1:20; y1=x1.*sin(x1); x2=10:.2:25; y2=50*x2; plot(x1,y1,'-b',x2,y2,'--g'); title('y1 is the blue line, y2 is the green line'); ylabel('y'); xlabel('x');

Círculo

x=2*cos([0:10:360]*(pi/180)); y=4*sin([0:10:360]*(pi/180)); plot(x,y) axis('square')

Cyan Dashed-dotted line

y=(x).^3;

plot(x,y)

plot(x,y,'-.c');

Red Dotted Line

y=(x).^3;

plot(x,y)

plot(x,y,':r');

Noise data

x1=[-3:.2:3];

y1=x1.^2+randn(size(x1));

p=polyfit(x1,y1,2);

x2=[-3:.5:3];

y2=polyval(p,x2);

plot(x1,y1,'og', x2,y2,'--c');

xlabel('Input');

ylabel('Output');

title('Noise data = "O" and Fitted Curve = “—-“ ');

>> grid;

Plota vários gráficos sobrepostos

x=-2:.1:2;

>> plot(x,sin(x),'-r');

>> hold on

>> plot(x, sin(x.^2),'--b');

>> plot(x,cos(x.^2),':g');

>> hold off

plot(0:.1:10,cos(0:.1:10))

date_string=date;

axes('position',[0 0 1 1],'visible','off');

Page 3: MATLAB - GRÁFICOS

text(1,0,date_string,'horizontalalignment','right',...

'verticalalignment','bottom');

Text(0,0,'Lower Left String', ...

'horizontalalignment','left', ...

'verticalalignment','bottom');

Text(1,1,'Top Right String', ...

'horizontalalignment’,’right', ...

'verticalalignment','top');

Text(0,1,'top Left

String', 'horizontalalignment', 'left',...

'verticalalignment','top');

Stem Plots

x=0:0.25:(3*pi);

stem(x,sin(x));

>> title('stem(x,sen(x))');

>> xlabel('x');

Area Plot

x=[0:9];

y=5*sin(x);

area(x,y,2,'facecolor','blue');

Using Plot3

t=0:0.1:10*pi;

>> x=exp(-t/20).*cos(t);

>> y=exp(-t/20).*sin(t);

>> z=t;

>> plot3(x,y,z);

>> xlabel('x');

>> ylabel('y');

>> zlabel('z');

Creating 3D Meshing Surface

[X,Y]=meshgrid(linspace(0,2*pi,50),linspace(0,pi,50));

Z=sin(X).*cos(Y);

mesh(X,Y,Z)

xlabel('x');ylabel('y');zlabel('z');

axis([0 2*pi 0 pi -1 1])

>> grid

>> w=0:pi/100:2*pi;

x1= sin(w);

x2= sin(w+pi/2);

x3= x1.*x2;

plot(w,x1,w,x2,w,x3)

legend('sin','cos','asin*cos')

Page 4: MATLAB - GRÁFICOS

Sistema de Coordenadas polares

theta=2*pi*[0:.01:1]; rho=0.5+cos(theta); polar(theta,rho)

theta=-(5*2*pi):.1:(5*2*pi); th=linspace(-pi,pi,length(x)); polar(th,abs(sin(x)./x));