Está en la página 1de 6

%%PRACTICA #2

>> A= {1 2 3; 3 4 5; 6 7 8}
A=
[1] [2] [3]
[3] [4] [5]
[6] [7] [8]
>> A= [1 2 3; 3 4 5; 6 7 8]
A=
1 2 3
3 4 5
6 7 8
>> B= [2 4 6]
B=
2

>> C= [5; 7; 9;]


C=
5
7
9
%%valores de ecuaciones
>> a=1; b=4; c=13;
>> %LAS SOLUCIONES SERAN
>> X1= (-b + sqrt(b^2 -4*a*c))/2*a
X1 =
-2.0000 + 3.0000i
>> X1= (-b - sqrt(b^2 -4*a*c))/2*a
>>
>> X2= (-b - sqrt(b^2 -4*a*c))/2*a
X2 =
-2.0000 - 3.0000i

>> %POLINOMIOS
>> p=[2 7 1]
p=
2

>> q=[1 0 3 0]
q=
1

>> p=[1 5 8 1]
p=
1

>> polyval(p,2)
ans =
45
>> %%calculamos un valor en el punto x=2
>> %--------------------------------------------->>
>> %%CALCULAR LAS RAICES DE UN POLINOMIO
>> p=[1 -3 9 13];
>> roots(p)
ans =
2.0000 + 3.0000i
2.0000 - 3.0000i
-1.0000
>>
>> %ENCONTRAR EL POLINOMIO CUANDO TENEMOS LAS RAICES
>> raices=[-1 2 +3i 2 -3i];
>> %RECONSTRUIMOS LAS RAICES
>> poly(raices)
ans =
1 -3

9 -23

0 36

>> raices=[-1 2+3i 2-3i];


>> poly(raices)
ans =
1 -3

9 13

>> %MULTIPLICAR Y DIVIDIR POLINOMIOS


>> p1=[1 -2 1]; p2=[1 1];
>> %MULTIPLICACION
>> conv(p1,p2)
ans =
1 -1 -1

>> %DIVISION
>> [c,r]=deconv(p1,p2)
c=
1 -3

r=
0

>> %VECTORES Y GRAFICAS


>> t=[0:0.5:4]
t=
0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 4.0000
>> %OPERACIONES VECTOR CON UN ESCALAR
>> %INTRODUCIMOS LOS DATOS
>> k=10; v1=[123]; v2=[456];
>>
>> k*v1
ans =
1230
>> k=10; v1=[1 2 3]; v2=[456];
>> k*v1

ans =
10 20 30
>> v1 + v2
ans =
457 458 459
>> k=10; v1=[1 2 3]; v2=[4 5 6];
>> v1 + v2
ans =
5

>> conv(v1,v2)
ans =
4 13 28 27 18
>> %GRAFICAS DE FUNCIONES EN 2D Y 3D
>> t=[0:0.1:10]; %DOMINIO DE REPRESENTACION
>> y=10*exp(-t).*sin(5*t);
>> plot(t,y) %DIBUJA LA GRAFICA
>> grid %ACTIVA LA REJILLA
>> xlabel('TIEMPO(s)') % ETIQUETA EL EJE X
>> ylabel('y(t)') %ETIQUETA EL EJE Y
>> title('SENOIDE AMORTIGUADO') % TITULO

t=[0:0.1:10]; %DOMINIO DE REPRESENTACION


>> y=10*exp(-t).*sin(5*t);
>> plot(t,y) %DIBUJA LA GRAFICA
>> grid %ACTIVA LA REJILLA
>> xlabel('TIEMPO(s)') % ETIQUETA EL EJE X
>> ylabel('y(t)') %ETIQUETA EL EJE Y
>> title('SENOIDE AMORTIGUADO') % TITULO
>> plot(t,y,'g*') %COLOR A LA GRAFICA

>>
>> %GRAFICAS MULTIPLES
>> t=[0:pi/180:4*pi]; %INTERVALO DE INTERPRETACION
>> y1=sin(t);
>> y2=cos(t);
>> plot(t,y1,'r o',t,y2,'g-')

>> %GRAFICAS MULTIPLES


>> t=[0:pi/180:4*pi]; %INTERVALO DE INTERPRETACION
>> y1=sin(t);
>> y2=cos(t);
>> plot(t,y1,'r o',t,y2,'g-')
>>
>>
>> %graficas multiples
>> t=o.0.1:10; %intervalo de representacion
t=o.0.1:10; %intervalo de representacion
|
Error: Unexpected MATLAB expression.
>> t=0:0.1:10; %intervalo de representacion
>> subplot(2,2,1) % primera subventana de la matriz de graficos 2x2
>> y1=exp(-t);
>> plot(t,y1)
>> subplot(2,2,2); %segunda subventana
>> y2=t.*exp(-t);
>> plot(t,y2)
>> subplot(2,2,3) % tercera subventana
>> y3=exp(-t).*cos(t);
>> plot(t,y3)
>> subplot(2,2,4) %cuarta
>> y4=exp(t).*cos(t);
>> plot(t,y4)

También podría gustarte