Está en la página 1de 9

Grficas simples en 2-D

>> x=linspace(0,2*pi,30)
x=
Columns 1 through 16
0 0.2167 0.4333 0.6500 0.8666 1.0833 1.3000 1.5166 1.7333 1.9500 2.1666
2.3833 2.5999 2.8166 3.0333 3.2499
Columns 17 through 30
3.4666 3.6832 3.8999 4.1166 4.3332 4.5499 4.7666 4.9832 5.1999 5.4165
5.6332 5.8499 6.0665 6.2832
>> y=sin(x)
y=
Columns 1 through 16
0 0.2150 0.4199 0.6052 0.7622 0.8835 0.9635 0.9985 0.9868 0.9290 0.8277
0.6877 0.5156 0.3193 0.1081 -0.1081
Columns 17 through 30
-0.3193 -0.5156 -0.6877 -0.8277 -0.9290 -0.9868 -0.9985 -0.9635 -0.8835 -0.7622 0.6052 -0.4199 -0.2150 -0.0000
>> plot(x,y)

>> z=cos(x)
z=
Columns 1 through 16

1.0000 0.9766 0.9076 0.7961 0.6474 0.4684 0.2675 0.0541 -0.1618 -0.3701 0.5612 -0.7260 -0.8569 -0.9477 -0.9941 -0.9941
Columns 17 through 30
-0.9477 -0.8569 -0.7260 -0.5612 -0.3701 -0.1618 0.0541 0.2675 0.4684 0.6474
0.7961 0.9076 0.9766 1.0000
>> plot(x,y,x,z)

>> plot(x,y,x,2*y.*z,'--')

>> plot(x,y)

>> hold on
>> plot(x,2*y.*z,'--')

>> hold off


>> grid

>> xlabel('Variable independiente x')


>> ylabel('Variable independiente')
>> title('2sin(x)cos(x)=sin(2x)')

>> plot3(y,z,x),grid

>> x=linspace(0,2*pi,30)

x=

Columns 1 through 16

0 0.2167 0.4333 0.6500 0.8666 1.0833 1.3000 1.5166 1.7333 1.9500 2.1666
2.3833 2.5999 2.8166 3.0333 3.2499

Columns 17 through 30

3.4666 3.6832 3.8999 4.1166 4.3332 4.5499 4.7666 4.9832 5.1999 5.4165
5.6332 5.8499 6.0665 6.2832

>> y=sin(x)

y=

Columns 1 through 16

0 0.2150 0.4199 0.6052 0.7622 0.8835 0.9635 0.9985 0.9868 0.9290 0.8277
0.6877 0.5156 0.3193 0.1081 -0.1081

Columns 17 through 30

-0.3193 -0.5156 -0.6877 -0.8277 -0.9290 -0.9868 -0.9985 -0.9635 -0.8835 -0.7622 0.6052 -0.4199 -0.2150 -0.0000

>> z=cos(x)

z=

Columns 1 through 16

1.0000 0.9766 0.9076 0.7961 0.6474 0.4684 0.2675 0.0541 -0.1618 -0.3701 0.5612 -0.7260 -0.8569 -0.9477 -0.9941 -0.9941

Columns 17 through 30

-0.9477 -0.8569 -0.7260 -0.5612 -0.3701 -0.1618 0.0541 0.2675 0.4684 0.6474
0.7961 0.9076 0.9766 1.0000

>> w=[y;z]

w=

Columns 1 through 16

0 0.2150 0.4199 0.6052 0.7622 0.8835 0.9635 0.9985 0.9868 0.9290 0.8277
0.6877 0.5156 0.3193 0.1081 -0.1081
1.0000 0.9766 0.9076 0.7961 0.6474 0.4684 0.2675 0.0541 -0.1618 -0.3701 0.5612 -0.7260 -0.8569 -0.9477 -0.9941 -0.9941

Columns 17 through 30

-0.3193 -0.5156 -0.6877 -0.8277 -0.9290 -0.9868 -0.9985 -0.9635 -0.8835 -0.7622 0.6052 -0.4199 -0.2150 -0.0000
-0.9477 -0.8569 -0.7260 -0.5612 -0.3701 -0.1618 0.0541 0.2675 0.4684 0.6474
0.7961 0.9076 0.9766 1.0000

>> plot(x,w),title('Figura 1')

>> figure(2)
>> plot(w,x),title('Figura 2')

>> plot(x,y,'k-',x,z,'r--',x,y,'ko')

>> grid
>> xlabel('Variable independiente x')
>> ylabel('Variable dependiente y z')
>> title('Curvas del seno y coseno')
>> text(2.5,0.7,'sin(x)')
>> gtext('cos(x)')
>> subplot(2,2,1)
>> grid off,plot(x,y),axis off,title('sin(x)')
>> subplot(2,2,2)
>> grid,plot(x,z),axis on,title('cos(x)')
>> subplot(2,2,3)
>> grid off,plot(x,2*y.*z),axis ij
>> subplot(2,2,4)
>> plot(x,y./z),axis ('xy','normal')
>> grid on,title('sin(x)/cos(x)')
>> subplot(2,2,2)
>> title('cos(x)')
>> subplot(2,2,3),grid
>> title('2sin(x)cos(x)')

>> subplot(1,1,1)
>> plot(x,y./z)
>> grid,title('sin(x)/cos(x)')

>> zoom on

>> zoom off

También podría gustarte