Matlab - graficar por medio de funciones

 
Vista:

graficar por medio de funciones

Publicado por andres (7 intervenciones) el 13/04/2016 17:17:02
Hola buen día

tengo el siguiente codigo para graficar, y quiero programar dicho codigo en una funcion

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
%======> Datos de entrada
V=120;
alpha=30*pi/180;
betha=pi;
ciclos=3;
wt = 0:2*pi/1000:2*pi;
vs = sqrt(2)*V*sin(wt);
beta = pi;
vo = ((wt>=0)&(wt<alpha)).*0+((wt>=alpha)&(wt<beta)).*(vs)+((wt>=beta)&(wt<2*pi)).*0;
 
%======> codigo a llamar por medio de una funcion graficar
 
figure('NumberTitle','off','Name','Voltaje de salida del convertidor & Voltaje de la fuente')
dx = 2*pi/1000;
yy=repmat(vo,1,ciclos);
xx = (1:length(yy))*dx;
plot(xx*180/pi,yy,'k','LineWidth',1.5)
hold on
dx1 = 2*pi/1000;
yy1=repmat(vs,1,ciclos);
xx1 = (1:length(yy1))*dx1;
plot(xx1*180/pi,yy1,'-.r')
set(gcf,'color','w');
xlim ([0 360*ciclos])
xlabel('\textbf{$\omega t~[^{o}]$}','Interpreter','latex','fontsize',12);
ylabel('\textbf{$v_{o}~[V]$, $v_s~[V]$}','Interpreter','latex','fontsize',12);
title(sprintf('Vrms=%f, V{max}=%f',V,max(V*sqrt(2))));
legend('$v_o$','$v_s$')
h = legend;
set(h, 'interpreter', 'latex','fontsize',12)
grid on
%---------------------------------------------------------------------------
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder