Está en la página 1de 11

classdef app1 < matlab.apps.

AppBase

% Properties that correspond to app components

properties (Access = public)

UIFigure matlab.ui.Figure

r2mEditFieldLabel matlab.ui.control.Label

r2 matlab.ui.control.NumericEditField

MECANISMOEMPUJAPAQUETESLabel matlab.ui.control.Label

DATOSDEENTRADALabel matlab.ui.control.Label

DATOSDESALIDALabel matlab.ui.control.Label

r3mEditFieldLabel matlab.ui.control.Label

r3 matlab.ui.control.NumericEditField

r4mEditFieldLabel matlab.ui.control.Label

r4 matlab.ui.control.NumericEditField

r7mEditFieldLabel matlab.ui.control.Label

r7 matlab.ui.control.NumericEditField

Image matlab.ui.control.Image

r5mEditFieldLabel matlab.ui.control.Label

r5 matlab.ui.control.NumericEditField

r1mEditFieldLabel matlab.ui.control.Label

r1 matlab.ui.control.NumericEditField

w2RPMEditFieldLabel matlab.ui.control.Label

w2 matlab.ui.control.NumericEditField

teta2EditFieldLabel matlab.ui.control.Label

teta2 matlab.ui.control.NumericEditField

r6mEditFieldLabel matlab.ui.control.Label

r6 matlab.ui.control.NumericEditField

w5radsEditFieldLabel matlab.ui.control.Label

w5 matlab.ui.control.NumericEditField
teta5EditFieldLabel matlab.ui.control.Label

teta5 matlab.ui.control.NumericEditField

VDmsEditFieldLabel matlab.ui.control.Label

vd matlab.ui.control.NumericEditField

CALCULARButton matlab.ui.control.Button

GRFICASButton matlab.ui.control.Button

end

% Callbacks that handle component events

methods (Access = private)

% Button pushed function: CALCULARButton

function CALCULARButtonPushed(app, event)

teta2 = app.teta2.Value; %leer datos de entrada

r2 = app.r2.Value;

r1 = app.r1.Value;

r3 = app.r3.Value;

r4 = app.r4.Value;

r5 = app.r5.Value;

r7 = app.r7.Value;

%ya estarian todos los datos de entrada de posición

w = app.w2.Value;

w2 = w*2*pi/60;

% y con este ultimo terminariamos todos los datos de entrada

%primero definimos los k1 k2 k3 k4 k5, ya que necesitamos una

%correlacion con la formula para un mecanismo de cuatro barras

%lazo vectorial 1

k1 = r1/r2;
k2 = r1/r4;

k3 = (r1^2+r2^2+r3^2+r4^2)/(2*r2*r4);

k4 = r1/r3;

k5 = (r4^2-r1^2-r2^2-r3^2)/(2*r2*r3);

teta20 = teta2 + 28.39;

A = cosd(teta2)-k1-k2*cosd(teta2)+k3;

B = -2*sind(teta2);

C = k1-(k2+1)*cosd(teta2)+k3;

D = cosd(teta2)-k1-k4*cosd(teta2)+k5;

E = -2*sind(teta2);

F = k1-(k4-1)*cosd(teta2)+k5;

teta30 = 2*atand((-E-sqrt(E^2-4*D*F))/(2*D));

teta40 = 2*atand((-B-sqrt(B^2-4*A*C))/(2*A));

teta3 = teta30-28.39;

teta4 = teta40-28.39;

%lazo vectorial 2 posición

%colocamos directamente las ecuaciones calculadas

teta7 = teta4 + 29.2;

teta5 = asind((r2*sind(teta2)+r3*sind(teta3)+r7*sind(teta7)-r1)/r5);

r6 = r5*cosd(teta5)-r2*cosd(teta2)-r3*cosd(teta3)-r7*cosd(teta7);

%lazo vectorial 1 -Velocidad


w3 = (r2*w2*sind(teta2)-tand(teta4)*r2*w2*cosd(teta2))/(tand(teta4)*r3*cosd(teta3)-
r3*sind(teta3));

w4 = (r2*w2*cosd(teta2)+r3*w2*cosd(teta3))/(r4*cosd(teta4));

w7 = w4;

%lazo vectorial 2 -velocidad

w5 = (r2*w2*cosd(teta2)+r3*w3*cosd(teta3)+r7*w7*cosd(teta7))/(r5*cosd(teta5));

vd = r2*w2*sind(teta2)+r3*w3*sind(teta3)+r7*w7*sind(teta7)-r5*w5*sind(teta5);

%datos de salida

app.teta5.Value = teta5;

app.r6.Value = r6;

app.w5.Value = w5;

app.vd.Value = vd;

end

end

% Component initialization

methods (Access = private)

% Create UIFigure and components

function createComponents(app)

% Create UIFigure and hide until all components are created

app.UIFigure = uifigure('Visible', 'off');

app.UIFigure.Position = [100 100 640 480];

app.UIFigure.Name = 'UI Figure';


% Create r2mEditFieldLabel

app.r2mEditFieldLabel = uilabel(app.UIFigure);

app.r2mEditFieldLabel.HorizontalAlignment = 'right';

app.r2mEditFieldLabel.Position = [27 366 37 22];

app.r2mEditFieldLabel.Text = 'r2 (m)';

% Create r2

app.r2 = uieditfield(app.UIFigure, 'numeric');

app.r2.Editable = 'off';

app.r2.Position = [79 366 36 22];

app.r2.Value = 0.1;

% Create MECANISMOEMPUJAPAQUETESLabel

app.MECANISMOEMPUJAPAQUETESLabel = uilabel(app.UIFigure);

app.MECANISMOEMPUJAPAQUETESLabel.Position = [207 446 200 22];

app.MECANISMOEMPUJAPAQUETESLabel.Text = 'MECANISMO EMPUJA PAQUETES';

% Create DATOSDEENTRADALabel

app.DATOSDEENTRADALabel = uilabel(app.UIFigure);

app.DATOSDEENTRADALabel.Position = [52 413 127 22];

app.DATOSDEENTRADALabel.Text = 'DATOS DE ENTRADA';

% Create DATOSDESALIDALabel

app.DATOSDESALIDALabel = uilabel(app.UIFigure);

app.DATOSDESALIDALabel.Position = [358 413 111 22];

app.DATOSDESALIDALabel.Text = 'DATOS DE SALIDA';

% Create r3mEditFieldLabel

app.r3mEditFieldLabel = uilabel(app.UIFigure);
app.r3mEditFieldLabel.HorizontalAlignment = 'right';

app.r3mEditFieldLabel.Position = [27 328 37 22];

app.r3mEditFieldLabel.Text = 'r3 (m)';

% Create r3

app.r3 = uieditfield(app.UIFigure, 'numeric');

app.r3.Editable = 'off';

app.r3.Position = [79 328 36 22];

app.r3.Value = 0.4;

% Create r4mEditFieldLabel

app.r4mEditFieldLabel = uilabel(app.UIFigure);

app.r4mEditFieldLabel.HorizontalAlignment = 'right';

app.r4mEditFieldLabel.Position = [27 289 37 22];

app.r4mEditFieldLabel.Text = 'r4 (m)';

% Create r4

app.r4 = uieditfield(app.UIFigure, 'numeric');

app.r4.Editable = 'off';

app.r4.Position = [79 289 36 22];

app.r4.Value = 0.3;

% Create r7mEditFieldLabel

app.r7mEditFieldLabel = uilabel(app.UIFigure);

app.r7mEditFieldLabel.HorizontalAlignment = 'right';

app.r7mEditFieldLabel.Position = [26 251 37 22];

app.r7mEditFieldLabel.Text = 'r7 (m)';

% Create r7
app.r7 = uieditfield(app.UIFigure, 'numeric');

app.r7.Editable = 'off';

app.r7.Position = [78 251 45 22];

app.r7.Value = 0.32;

% Create Image

app.Image = uiimage(app.UIFigure);

app.Image.Position = [198 251 168 99];

% Create r5mEditFieldLabel

app.r5mEditFieldLabel = uilabel(app.UIFigure);

app.r5mEditFieldLabel.HorizontalAlignment = 'right';

app.r5mEditFieldLabel.Position = [30 210 37 22];

app.r5mEditFieldLabel.Text = 'r5 (m)';

% Create r5

app.r5 = uieditfield(app.UIFigure, 'numeric');

app.r5.Editable = 'off';

app.r5.Position = [82 210 41 22];

app.r5.Value = 0.65;

% Create r1mEditFieldLabel

app.r1mEditFieldLabel = uilabel(app.UIFigure);

app.r1mEditFieldLabel.HorizontalAlignment = 'right';

app.r1mEditFieldLabel.Position = [26 176 37 22];

app.r1mEditFieldLabel.Text = 'r1 (m)';

% Create r1

app.r1 = uieditfield(app.UIFigure, 'numeric');


app.r1.Editable = 'off';

app.r1.Position = [78 176 45 22];

app.r1.Value = 0.3;

% Create w2RPMEditFieldLabel

app.w2RPMEditFieldLabel = uilabel(app.UIFigure);

app.w2RPMEditFieldLabel.HorizontalAlignment = 'right';

app.w2RPMEditFieldLabel.Position = [327 155 59 22];

app.w2RPMEditFieldLabel.Text = 'w2 (RPM)';

% Create w2

app.w2 = uieditfield(app.UIFigure, 'numeric');

app.w2.Position = [401 155 100 22];

% Create teta2EditFieldLabel

app.teta2EditFieldLabel = uilabel(app.UIFigure);

app.teta2EditFieldLabel.HorizontalAlignment = 'right';

app.teta2EditFieldLabel.Position = [157 155 35 22];

app.teta2EditFieldLabel.Text = 'teta 2';

% Create teta2

app.teta2 = uieditfield(app.UIFigure, 'numeric');

app.teta2.Position = [207 155 100 22];

% Create r6mEditFieldLabel

app.r6mEditFieldLabel = uilabel(app.UIFigure);

app.r6mEditFieldLabel.HorizontalAlignment = 'right';

app.r6mEditFieldLabel.Position = [376 328 37 22];

app.r6mEditFieldLabel.Text = 'r6 (m)';


% Create r6

app.r6 = uieditfield(app.UIFigure, 'numeric');

app.r6.Position = [428 328 100 22];

% Create w5radsEditFieldLabel

app.w5radsEditFieldLabel = uilabel(app.UIFigure);

app.w5radsEditFieldLabel.HorizontalAlignment = 'right';

app.w5radsEditFieldLabel.Position = [364 289 59 22];

app.w5radsEditFieldLabel.Text = 'w5 (rad/s)';

% Create w5

app.w5 = uieditfield(app.UIFigure, 'numeric');

app.w5.Position = [438 289 100 22];

% Create teta5EditFieldLabel

app.teta5EditFieldLabel = uilabel(app.UIFigure);

app.teta5EditFieldLabel.HorizontalAlignment = 'right';

app.teta5EditFieldLabel.Position = [377 357 35 22];

app.teta5EditFieldLabel.Text = 'teta 5';

% Create teta5

app.teta5 = uieditfield(app.UIFigure, 'numeric');

app.teta5.Position = [427 357 100 22];

% Create VDmsEditFieldLabel

app.VDmsEditFieldLabel = uilabel(app.UIFigure);

app.VDmsEditFieldLabel.HorizontalAlignment = 'right';

app.VDmsEditFieldLabel.Position = [369 251 53 22];


app.VDmsEditFieldLabel.Text = 'VD (m/s)';

% Create vd

app.vd = uieditfield(app.UIFigure, 'numeric');

app.vd.Position = [437 251 100 22];

% Create CALCULARButton

app.CALCULARButton = uibutton(app.UIFigure, 'push');

app.CALCULARButton.ButtonPushedFcn = createCallbackFcn(app,
@CALCULARButtonPushed, true);

app.CALCULARButton.Position = [134 76 100 22];

app.CALCULARButton.Text = 'CALCULAR';

% Create GRFICASButton

app.GRFICASButton = uibutton(app.UIFigure, 'push');

app.GRFICASButton.Position = [353 76 100 22];

app.GRFICASButton.Text = 'GRÁFICAS';

% Show the figure after all components are created

app.UIFigure.Visible = 'on';

end

end

% App creation and deletion

methods (Access = public)

% Construct app

function app = app1


% Create UIFigure and components

createComponents(app)

% Register the app with App Designer

registerApp(app, app.UIFigure)

if nargout == 0

clear app

end

end

% Code that executes before app deletion

function delete(app)

% Delete UIFigure when app is deleted

delete(app.UIFigure)

end

end

end

También podría gustarte