Está en la página 1de 17

MODELACIÓN DE SISTEMAS DE ENERGÍA ELÉCTRICA

PRACTICA Nº 1
>> 2+3

ans =

>> 3-2

ans =

>> 2*3

ans =

>> 1 / 2

ans =

0.5000

>> 2^2

ans =

>> 2\1

ans =

0.5000

>> 2.*3

ans =

>> 1./2
ans =

0.5000

>> 2.^2

ans =

>> pi

ans =

3.1416

>> sqrt(pi)

ans =

1.7725

>> whos
Name Size Bytes Class Attributes

ans 1x1 8 double

>> x=0:10

x=

0 1 2 3 4 5 6 7 8 9 10

>> size(x)

ans =

1 11

>> x=0:10;
>> size(x)

ans =

1 11

>> x

--------------------------------------------------------------0--------------------------------------------------------------

Gráfica Seno
x=

0 1 2 3 4 5 6 7 8 9 10

>> x=0:0.1:10;
>> z=sin(x);
>> plot(x,z),grid

--------------------------------------------------------------0--------------------------------------------------------------

Método Matricial

>> a=[1 2; 2 -1];


>> b=[4; 3];
>> z=a\b

z=

2
1

--------------------------------------------------------------0--------------------------------------------------------------
[x y] = meshgrid(-8 : 0.5 : 8);
>> r = sqrt(x.^2 + y.^2) + eps;
>> z = sin(r)./ r;
>> mesh(z);

>>surf(z), shading flat

--------------------------------------------------------------0--------------------------------------------------------------
Probando los sonidos

>> load handel


>> sound (y, Fs)

Tierra vista desde el espacio

>> load earth


>> image(X); colormap(map)
>> axis image

>> why
The bald and not excessively bald and not excessively smart hamster obeyed a terrified and
not excessively terrified hamster.
>> why
To fool the tall good and smart system manager.
>> why
The rich rich and tall and good system manager suggested it.

--------------------------------------------------------------0--------------------------------------------------------------

1. En el disco C crear carpeta con el nombre: work_m


2. New créate document
3. Gravar archivo con nombre ejemplo1 todo junto

x = 0: pi/20: 6*pi;
plot(x, exp(-0.2*x) .* sin(x), 'r'),grid

‘b’
--------------------------------------------------------------0--------------------------------------------------------------
>> x=[1 3 0 -1 5]

x=

1 3 0 -1 5

>> x'

ans =

1
3
0
-1
5
--------------------------------------------------------------0--------------------------------------------------------------

>> a=[1 2 3; 4 5 6]

a=

1 2 3
4 5 6
--------------------------------------------------------------0--------------------------------------------------------------

>> x=0:30:180;
>> tabla = [x' sin(x*pi/180)']

tabla =
0 0
30.0000 0.5000
60.0000 0.8660
90.0000 1.0000
120.0000 0.8660
150.0000 0.5000
180.0000 0.0000

--------------------------------------------------------------0--------------------------------------------------------------

>> eye(4)

ans =

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

>> zeros(3,5)

ans =

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

>> zeros(4)

ans =

0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0

>> ones(3)

ans =

1 1 1
1 1 1
1 1 1

>> ones(2,4)

ans =

1 1 1 1
1 1 1 1

>> ones(3)

ans =

1 1 1
1 1 1
1 1 1

>> ones(2,4)

ans =

1 1 1 1
1 1 1 1

Seudo aleatorio

>> rand(3) ---

ans =

0.7513 0.6991 0.5472


0.2551 0.8909 0.1386
0.5060 0.9593 0.1493

--------------------------------------------------------------0--------------------------------------------------------------

Movimiento vertical bajo gravedad

g=9.8
vl=60;
t=0:0.01:12.3;
d=vl*t-(1/2)*g*t.^2
plot(t,d), title('Movimiento vertical bajo gravedad')
xlabel('Tiempo')
ylabel('Desplazamiento vertical'),grid
--------------------------------------------------------------0--------------------------------------------------------------

Números Complejos

>> a=1; b=4; c=13;


>> x1=(-b+sqrt(b*b-4*a*c))/(2*a)

x1 =

-2.0000 + 3.0000i

>> x2=(-b-sqrt(b^2-4*a*c))/(2*a)

x2 =

-2.0000 - 3.0000i

>> %comprobando
>> a*x1^2+b*x1+c

ans =

--------------------------------------------------------------0--------------------------------------------------------------

INPUT

>> n=input('Teclee el numero de ecuaciones =')


Teclee el numero de ecuaciones =10
n=

10

>> nombre=input('Como te llamas?','s')


Como te

nombre =

--------------------------------------------------------------0--------------------------------------------------------------

DISP

>> disp('El programa ha terminado')


El programa ha terminado
>>
>> A=rand(4,4)

A=

0.2575 0.2435 0.2511 0.8308


0.8407 0.9293 0.6160 0.5853
0.2543 0.3500 0.4733 0.5497
0.8143 0.1966 0.3517 0.9172

>> disp(A)
0.2575 0.2435 0.2511 0.8308
0.8407 0.9293 0.6160 0.5853
0.2543 0.3500 0.4733 0.5497
0.8143 0.1966 0.3517 0.9172
--------------------------------------------------------------0--------------------------------------------------------------

Caso proyectil (pelota de golf)

clear
clc
%Problema del proyectil v(pelota de golf)con resistencia cero del aire
en
%un g=gravedad.
disp (' Movimiento de una pelota de golf')
disp (' ---------------------------------')
disp (' ')
%1. Definición de las variables de entrada
g = 9.81; %Gravedad en m/s
vo=input('¿Cual es la Velocidad de lanzamiento en m/s? ')
tho=input('¿Cual es el ángulo de lanzamiento en grados? ')
tho = pi*tho/180; %Conversiòn de grados a radianes.
%2. Calculo del rango y duración del vuelo
txmax = (2*vo/g) * sin(tho);
xmax = txmax * vo * cos(tho);
%3. Calculo de la secuencia de tiempo por pasos para calcular la
%trayectoria.
dt = txmax/100;
t = 0:dt:txmax;
%4. Calculo de la trayectoria
x = (vo * cos(tho)) .* t;
y = (vo * sin(tho)) .* t - (g/2) .* t.^2;
%5. Calculo de la velocidad dy dirección angular del proyectil Nota
que
%vx=dx/dt, vy =dy/dt.
vx = vo * cos(tho);
vy = vo * sin(tho) - g.* t;
v = sqrt(vx.*vx + vy.*vy);
th = (180/pi) .* atan2(vy,vx);
%6. Calculo del tiempo, distancia horizontal a la máxima altitud
tymax = (vo/g) * sin(tho);
xymax = xmax/2;
ymax = (vo/2) * tymax * sin(tho);
%7. Mostrar resultados.
disp(['Rango en m = ',num2str(xmax),' Duración en s =
',num2str(txmax)])
disp(' ')
disp(['Maxima altitud en m = ',num2str(ymax),' Arriba en s =
',num2str(tymax)])
plot(x,y,'k',xmax,y(size(t)),'o',xmax/2,ymax,'o')
title(['Trayectoria de vuelo del Proyectil vo =',num2str(vo),' \theta
=',num2str(180*tho/pi)])
xlabel('x'), ylabel ('y') % Figura 1
figure % Crea una nueva.
plot(v,th,'r')
title('Velocidad del Proyectil vs. ángulo')
xlabel('v'), ylabel('\theta') % Figura 2.
%
%8. Stop.
%

Movimiento de una pelota de golf


---------------------------------

¿Cual es la Velocidad de lanzamiento en m/s? 10

vo =

10

¿Cual es el ángulo de lanzamiento en grados? 45

tho =

45

Rango en m = 10.1937 Duración en s = 1.4416

Maxima altitud en m = 2.5484 Arriba en s = 0.7208


--------------------------------------------------------------0--------------------------------------------------------------

MATRICES DE NÚMEROS

>> c=[3 12 10;17 18 35;7 10 24];


>> x=[4 0 0;6 6 0;0 3 5];
>> c

c=

3 12 10
17 18 35
7 10 24

>> x

x=

4 0 0
6 6 0
0 3 5

>> m=c*x

m=
84 102 50
176 213 175
88 132 120

>> suma=c+x

suma =

7 12 10
23 24 35
7 13 29

>> res=c-x

res =

-1 12 10
11 12 35
7 7 19

>> c

c=

3 12 10
17 18 35
7 10 24

>> c'

ans =

3 17 7
12 18 10
10 35 24

>> inversa=inv(c)

inversa =

-0.0646 0.1480 -0.1890


0.1283 -0.0016 -0.0512
-0.0346 -0.0425 0.1181

--------------------------------------------------------------0--------------------------------------------------------------

Múltiples Gráficos

clc
clear
disp('Múltiples gráficos')
disp('------------------')
[x,y] = meshgrid(-3:0.3:3);
z=x .* exp(-x.^2 - y.^2);
subplot(2,2,1)
mesh(z), title('subplot(2,2,1)')
subplot(2,2,2)
mesh(z)
view(-37.5,70),title('subplot(2,2,2)')
subplot(2,2,3)
mesh(z)
view(-37.5,-10),title('subplot(2,2,3)')
subplot(2,2,4)
mesh(z)
view(0,0),title('subplot(2,2,4)')

>> [x y]=meshgrid(-2:.2:2);
>> z=x.*exp(-x.^2-y.^2);
>> meshc(z)
>> a=zeros(30,30);
>> a(:,15) = 0.2*ones(30,1);
>> a(7,:) =0.1*ones(1,30);
>> a(15,15) = 1;
>> mesh (a)

También podría gustarte