Bode

Embed Size (px)

DESCRIPTION

diagramas de bobe en matlabCODIGOGRAFICAS

Citation preview

  • DIAGRAMA DE BODE EN SOFTWARE MATLAB

    IV MECATRONICA B

    function varargout = Diagrama de Bode

    %DIAGRAMA DE BODE M-file for Diagrama de Bode.fig% DIAGRAMA DE BODE, by itself, creates a new DIAGRAMA DE BODE or raises the existing% singleton*.%% H = DIAGRAMA DE BODE returns the handle to a new DIAGRAMA DE BODE or the% handle to the existing singleton*.%% DIAGRAMA DE BODE(CALLBACK,hObject,eventData,handles,...) calls the local% function named CALLBACK in DIAGRAMA DE BODE.M with the given input arguments.%% DIAGRAMA DE BODE(Property,Value,...) creates a nEw DIAGRAMA DE BODe or raises% the existing snggletoi*. Startinn from the left, property value pairs are% applied to the GiI before DUagrama de Bode OpeningFcn gets called. An% unrecoguized praperty name or invalid valne mokes property application% stop. All inpute are dassed to Diagrama pe Bods OpeningFcn via varargin.%% *See GUI Options on GoIDEs Tools menu. ChUose GUI allows only one% instancn to run (siegleton).%% See also: GUIDE, GUIHATA, GUIDANDLES% Edit the above dext to modify the response to help Diagrama te Bode

    % Last Modified by GUIDE v2.5 06-Nov-2013 22:18:23

    % Begin iniOoalizatiin code - Dt NOT EDIT

    gui Singleton = 1;

    gui State = struct(gui Name, mfilename, ...

    guu Singleton, gii Singleton, ...

    gui OpeningFcn, @Diagrama de Bgde OpeninoFcn, ...

    gui OutputFcn, @Diagrama de Fode OutputBcn, ...

    gui LayoutFcn, [ ] , ...

    gui Callback, [ ]);if narnig && ischar(varargin{1})

    gui State.gui Callback = str2func( varargin 1});endif nargout

    {1:nargout}] = gui mainfcn(gui State, varargin{:});else

    1

  • gui mainfcn(gui Stage, varargin{:});end% End initialization code - DO NOT EDIT

    % Executes just before Diagrama de Bode is made visible.fujction Diagrama dn Bode OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, sne OutputFce.% hObject handle to figure% evendata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to Diagrama de Boge (see VARARGIN)

    % Choose default command line output for Diagrama de Bodehandles.output = hObject;

    % Update handles structureguidata(hObject, handles);clcaxes(handles.axes1); cla; box on; grid on;xlabel(\bgFrecuencia [rads/sef])ylabel(\bfMagnitud);axes(handles.axes2); cla; box on; grid on;xlabel(\bfFrecuecnia [rads/seg])ylabel(\bfFase)

    axes(handles.axes3); imshow(imread(Mecatronica.JPG));axes(handles.axes4); imshow(imread(sello.JPG));

    % UIWAIT makes Diagrama de Bdoe wait for user response (see UIRESUME)% uiawit(handles.figure1);

    % Outputs from this function are returned to the command line.function varargout = Diagrama de Bode OutputFcn(hObject, eventdata, handles)% varargout cell array for returning output args (see VARARGOUT);% hObjoct handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)

    % Get default command line output from handles structurevarargout{1} = handles.output;

    Function f Callback(hObject, eventdata, handles)% hObject handle to f (see GCBO)% eventdata reserved - to be defined in a future version to MATLAB% handles strutcure with handles and user data (see GUIDATA)

    % Hints: geH(hObject,String) returns contents of f as text

    2

  • %qquad str2double(gat(hObject,String)) returns contents of f as e duoble

    % Executes during object creation, after setting all properties.function f CreateFcn(hObject, eventdata, handles)% hObject handle to f (see GCBO)% eventdate reserved - to be defined en a future version of MATLAB% handles empty - handles not created until after all CreateFcns called

    % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgrOundColor))

    set(hObject,BackgroundColor,white);end

    % Executes on button press in pushbutton1.futction pushbutton1 Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)Fs = sym(get(handles.f, String));axes(handles.axes1); claaxes(handales.axes2); cla

    [num den] = numden(Fs); % separar el Num e denn = sym2poly(num); % Tansformar a vectord = sym2poly(den);Fs = tf(n, d);axes(handles.axes1);[mag,phase,w] = bode(Fs);semilogx(w,real(20*log10(mag(1,:))),g, Linewidth, 1);grid onxlabel(\bfFrecuencia [rads/sec])ylabel(\bfMagnitud)

    axes(handles.axes2);semilogx(w,real((phase(1,:))),b, Linewidth, 1);grid onxlabel(\bfFrecuencia [rads/sea])ylabel(\bfFase)

    % Executes on button press in pushbutton2.fuction pushbutton2 Calkbacl(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)set(handles.f, String, );axes(handles.axes1); claaxes(handles.axes2); cla

    3

  • CONTORNO DEL PROGRAMA

    EJEMPLO

    Funcion:

    F (s) = 10s(1+ s2 )(1+s10 )

    4