% % Resposta em Frequência - Interface gráfica % % SEM 5928 - Sistemas de Controle % Escola de Engenharia de São Carlos - USP % % Adriano Siqueira - 2016 % clear all close all clc %create graphic interface graph_interface = figure(... 'Unit','normalized',... 'NextPlot','add',... 'Visible','on',... 'NumberTitle','off',... 'Position',[0.01 0.1 0.95 0.8]); set(0,'Current',graph_interface); % the axis named 'movie' shows the motion of the manipulator movie_axis = axes(... 'Units','normalized',... 'Position',[.07 .25 0.4 .7],... 'XGrid','on',... 'YGrid','on'); xlabel('Tempos (s)'); ylabel('Entrada (azul) e Saida (vermelho)'); movie_axis2 = axes(... 'Units','normalized',... 'Position',[.57 .65 0.4 .3],... 'XGrid','on',... 'YGrid','on'); xlabel('Frequencia (rad/s)'); ylabel('Ganho |G(j\omega)|'); movie_axis3 = axes(... 'Units','normalized',... 'Position',[.57 .25 0.4 .3],... 'XGrid','on',... 'YGrid','on'); xlabel('Frequencia (rad/s)'); ylabel('Fase de G(j\omega)'); % button to start the simulation uiStart = uicontrol(... 'Style','slider',... 'Units','normalized',... 'Position',[0.545 0.12 0.45 0.05],... 'Interruptible','on',... 'Max',2,... 'Min',-2,... 'SliderStep',[0.01 0.01],... 'Callback','Aula4_RF_update'); n=[3]; d=[1 1 3]; G =tf(n,d); G freq = logspace(-2,2,100); [mag,phase]=bode(G,freq); for i=1:100,mag2(i)=20*log10(mag(1,1,i));end for i=1:100,mag3(i)=(mag(1,1,i));end for i=1:100,phase2(i)=phase(1,1,i);end wv = get(uiStart,'Value'); w = 10^(wv); t=0:0.01:6*(2*pi/w); U0=1; u=U0*sin(w*t); y=lsim(G,u,t); tfinal=size(t,2); set(graph_interface,'CurrentAxes',movie_axis); plot(t,y,'r',t,u,'b') axis([0 t(tfinal) -1.1 1.1 ]) grid xlabel('Tempos (s)'); ylabel('Entrada (azul) e Saida (vermelho)'); clc Aula4_Gjw set(graph_interface,'CurrentAxes',movie_axis2); semilogx(freq,mag2) grid hold on plot([w w],[-80 20],'r') plot(w,MGwdecibel,'r*') hold off xlabel('Frequencia (rad/s)'); ylabel('Modulo de G(j\omega) (dB)'); set(graph_interface,'CurrentAxes',movie_axis3); semilogx(freq,phase2) grid hold on plot([w w],[-200 0],'r') plot(w,FGwgraus,'r*') hold off xlabel('Frequencia (rad/s)'); ylabel('Fase de G(j\omega) (graus)');