You are on page 1of 16

Universitatea POLITEHNICA din Bucuresti 

Student: Nutu Bogdan


Facultatea de Inginerie Mecanica si Mecatronica            Grupa: 541B sgr II
Departamentul de Mecatronica si Mecanica de Precizie
Laboratorul de Sisteme Ultraprecise de Mecanica Fina

Laborator Nr: 10
Interfata grafica utilizator

Enunţ: Sa se creeze o interfata grafica ce calculeaza masa, volumul si


momentul piesei din laboratorul 5 in functie de intrarile tastate.

Program:
classdef App10 < matlab.apps.AppBase

% Properties that correspond to app components


properties (Access = public)
UIFigure matlab.ui.Figure
Image matlab.ui.control.Image
Image2 matlab.ui.control.Image
IesireButton matlab.ui.control.Button
Label matlab.ui.control.Label
EditField matlab.ui.control.NumericEditField
Label_2 matlab.ui.control.Label
EditField_2 matlab.ui.control.NumericEditField
Label_3 matlab.ui.control.Label
EditField_3 matlab.ui.control.NumericEditField
Label_4 matlab.ui.control.Label
EditField_4 matlab.ui.control.NumericEditField
Label_5 matlab.ui.control.Label
EditField_5 matlab.ui.control.NumericEditField
Label_6 matlab.ui.control.Label
EditField_6 matlab.ui.control.NumericEditField
mmLabel matlab.ui.control.Label
mmLabel_2 matlab.ui.control.Label
mmLabel_3 matlab.ui.control.Label
mmLabel_4 matlab.ui.control.Label
mmLabel_5 matlab.ui.control.Label
mmLabel_6 matlab.ui.control.Label
mmLabel_7 matlab.ui.control.Label
mmLabel_8 matlab.ui.control.Label
mmLabel_9 matlab.ui.control.Label
L1EditFieldLabel matlab.ui.control.Label
L1EditField matlab.ui.control.NumericEditField
L2EditFieldLabel matlab.ui.control.Label
L2EditField matlab.ui.control.NumericEditField
L3EditFieldLabel matlab.ui.control.Label
L3EditField matlab.ui.control.NumericEditField
kgm3Label matlab.ui.control.Label
kgm3Label_2 matlab.ui.control.Label
Label_7 matlab.ui.control.Label
EditField_7 matlab.ui.control.NumericEditField
Label_8 matlab.ui.control.Label
EditField_8 matlab.ui.control.NumericEditField
Image3 matlab.ui.control.Image
RezultatePanel matlab.ui.container.Panel
AnsambluLabel matlab.ui.control.Label
VolumLabel matlab.ui.control.Label
MasaLabel matlab.ui.control.Label
MomentLabel matlab.ui.control.Label
m3Label matlab.ui.control.Label
kgLabel matlab.ui.control.Label
NmLabel matlab.ui.control.Label
EditField_9 matlab.ui.control.NumericEditField
EditField_10 matlab.ui.control.NumericEditField
EditField_11 matlab.ui.control.NumericEditField
CalculeazavolumulmasasimomentuldeinertieButton matlab.ui.control.Button
ResetButton matlab.ui.control.Button
CorpDropDownLabel matlab.ui.control.Label
CorpDropDown matlab.ui.control.DropDown
gauriEditFieldLabel matlab.ui.control.Label
gauriEditField matlab.ui.control.NumericEditField
mmLabel_12 matlab.ui.control.Label
L4EditFieldLabel matlab.ui.control.Label
L4EditField matlab.ui.control.NumericEditField
NutuLabel matlab.ui.control.Label
CalculatorvolummasasimomentalunuianasambluarborediscLabel
matlab.ui.control.Label
end

% Callbacks that handle component events


methods (Access = private)

% Button pushed function: IesireButton


function IesireButtonPushed(app, event)
closereq(); %inchidere fereastra (close request)
end

% Value changed function: CorpDropDown


function CorpDropDownValueChanged(app, event)
value = app.CorpDropDown.Value;
app.AnsambluLabel.Text = value;
if(value == "Ansamblu")
app.Image3.ImageSource = "pozaAnsamblu.png";
else
if(value == "Arbore")
app.Image3.ImageSource = "pozaButuc.png";
else
if(value == "Disc")
app.Image3.ImageSource = "pozaFlansa.png";
end
end
end
end

% Button pushed function:


% CalculeazavolumulmasasimomentuldeinertieButton
function CalculeazavolumulmasasimomentuldeinertieButtonPushed(app, event)
fiDisc = app.EditField.Value;
fiGauri = app.EditField_2.Value;
fiGaura = app.EditField_3.Value;
fiFusMic = app.EditField_4.Value;
fiFusMare = app.EditField_5.Value;
fiCapDisc = app.EditField_6.Value;
lFus = app.L1EditField.Value;
lDisc = app.L2EditField.Value;
lCapDisc = app.L3EditField.Value;
lFusMic = app.L4EditField.Value;
roBucsa = app.EditField_8.Value;
roDisc = app.EditField_7.Value;
nrGauri = app.gauriEditField.Value;
[vArbore, mArbore, jArbore]=momInertie(fiFusMare*10^-3, (lFus-2*lFusMic)*10^-3,
roBucsa, 0);
[vFlansa, mFlansa, jFlansa]=momInertie(fiFusMic*10^-3, lFusMic*10^-3, roBucsa,
0);
[vDiscInf, mDiscInf, jDiscInf]=momInertie(fiDisc*10^-3, lDisc*10^-3, roDisc, 0);
[vDiscSup, mDiscSup, jDiscSup]=momInertie(fiCapDisc*10^-3, (lCapDisc-lDisc)*10^-
3, roDisc, 0);
[vGaura, mGaura, jGaura]=momInertie(fiGaura*10^-3, lDisc*10^-3, roDisc,
fiGauri/2*10^-3);
[vArboreInt, mArboreInt, jArboreInt]=momInertie(fiFusMare*10^-3, lCapDisc*10^-3,
roDisc, 0);
vArboreTotal=vArbore+2*vFlansa;
mArboreTotal=mArbore+2*mFlansa;
jArboreTotal=jArbore+2*jFlansa;
vDisc=vDiscInf+vDiscSup-nrGauri*vGaura-vArboreInt;
mDisc=mDiscInf+mDiscSup-nrGauri*mGaura-mArboreInt;
jDisc=jDiscInf+jDiscSup-nrGauri*jGaura-jArboreInt;
vTotal = vDisc+vArboreTotal;
mTotal = mDisc+mArboreTotal;
jTotal = jDisc + jArboreTotal;
if(app.CorpDropDown.Value == "Ansamblu")
app.EditField_9.Value = vTotal;
app.EditField_10.Value = mTotal;
app.EditField_11.Value = jTotal;
else
if(app.CorpDropDown.Value == "Arbore")
app.EditField_9.Value = vArboreTotal;
app.EditField_10.Value = mArboreTotal;
app.EditField_11.Value = jArboreTotal;
else
if(app.CorpDropDown.Value == "Disc")
app.EditField_9.Value = vDisc;
app.EditField_10.Value = mDisc;
app.EditField_11.Value = jDisc;
end
end
end
end

% Button pushed function: ResetButton


function ResetButtonPushed(app, event)
app.EditField_9.Value = 0;
app.EditField_10.Value = 0;
app.EditField_11.Value = 0;
app.Image3.ImageSource = "pozaAnsamblu.png";
app.CorpDropDown.Value = "Ansamblu";
app.EditField.Value = 0;
app.EditField_2.Value = 0;
app.EditField_3.Value = 0;
app.EditField_4.Value = 0;
app.EditField_5.Value = 0;
app.EditField_6.Value = 0;
app.L1EditField.Value = 0;
app.L2EditField.Value = 0;
app.L3EditField.Value = 0;
app.L4EditField.Value = 0;
app.EditField_7.Value = 0;
app.EditField_8.Value = 0;
app.gauriEditField.Value = 0;
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.Color = [0.5216 0.7804 0.9294];
app.UIFigure.Position = [100 100 923 454];
app.UIFigure.Name = 'MATLAB App';

% Create Image
app.Image = uiimage(app.UIFigure);
app.Image.Tag = 'logo1';
app.Image.Position = [21 336 100 100];
app.Image.ImageSource = 'logo-fimm.png';

% Create Image2
app.Image2 = uiimage(app.UIFigure);
app.Image2.Tag = 'logo2';
app.Image2.Position = [816 336 100 100];
app.Image2.ImageSource = 'logo-upb.png';

% Create IesireButton
app.IesireButton = uibutton(app.UIFigure, 'push');
app.IesireButton.ButtonPushedFcn = createCallbackFcn(app, @IesireButtonPushed,
true);
app.IesireButton.Tag = 'exit';
app.IesireButton.Position = [778 23 100 38];
app.IesireButton.Text = 'Iesire';

% Create Label
app.Label = uilabel(app.UIFigure);
app.Label.HorizontalAlignment = 'right';
app.Label.Position = [29 283 29 22];
app.Label.Text = 'ϕ1 = ';

% Create EditField
app.EditField = uieditfield(app.UIFigure, 'numeric');
app.EditField.Tag = 'fiDisc';
app.EditField.Position = [66 283 35 22];

% Create Label_2
app.Label_2 = uilabel(app.UIFigure);
app.Label_2.HorizontalAlignment = 'right';
app.Label_2.Position = [26 249 32 22];
app.Label_2.Text = 'ϕ2 = ';

% Create EditField_2
app.EditField_2 = uieditfield(app.UIFigure, 'numeric');
app.EditField_2.Tag = 'inFiGauri';
app.EditField_2.Position = [66 249 35 22];

% Create Label_3
app.Label_3 = uilabel(app.UIFigure);
app.Label_3.HorizontalAlignment = 'right';
app.Label_3.Position = [26 212 32 22];
app.Label_3.Text = 'ϕ3 = ';

% Create EditField_3
app.EditField_3 = uieditfield(app.UIFigure, 'numeric');
app.EditField_3.Tag = 'inFiGaura';
app.EditField_3.Position = [66 215 35 22];

% Create Label_4
app.Label_4 = uilabel(app.UIFigure);
app.Label_4.HorizontalAlignment = 'right';
app.Label_4.Position = [26 182 32 22];
app.Label_4.Text = 'ϕ4 = ';

% Create EditField_4
app.EditField_4 = uieditfield(app.UIFigure, 'numeric');
app.EditField_4.Tag = 'inFiFusMic';
app.EditField_4.Position = [66 181 35 22];

% Create Label_5
app.Label_5 = uilabel(app.UIFigure);
app.Label_5.HorizontalAlignment = 'right';
app.Label_5.Position = [26 152 32 22];
app.Label_5.Text = 'ϕ5 = ';
% Create EditField_5
app.EditField_5 = uieditfield(app.UIFigure, 'numeric');
app.EditField_5.Tag = 'inFiFusMare';
app.EditField_5.Position = [66 147 35 22];

% Create Label_6
app.Label_6 = uilabel(app.UIFigure);
app.Label_6.HorizontalAlignment = 'right';
app.Label_6.Position = [26 116 32 22];
app.Label_6.Text = 'ϕ6 = ';

% Create EditField_6
app.EditField_6 = uieditfield(app.UIFigure, 'numeric');
app.EditField_6.Tag = 'inFiCapDisc';
app.EditField_6.Position = [66 113 35 22];

% Create mmLabel
app.mmLabel = uilabel(app.UIFigure);
app.mmLabel.Position = [109 283 25 22];
app.mmLabel.Text = 'mm';

% Create mmLabel_2
app.mmLabel_2 = uilabel(app.UIFigure);
app.mmLabel_2.Position = [109 249 25 22];
app.mmLabel_2.Text = 'mm';

% Create mmLabel_3
app.mmLabel_3 = uilabel(app.UIFigure);
app.mmLabel_3.Position = [109 215 25 22];
app.mmLabel_3.Text = 'mm';

% Create mmLabel_4
app.mmLabel_4 = uilabel(app.UIFigure);
app.mmLabel_4.Position = [109 182 25 22];
app.mmLabel_4.Text = 'mm';

% Create mmLabel_5
app.mmLabel_5 = uilabel(app.UIFigure);
app.mmLabel_5.Position = [109 149 25 22];
app.mmLabel_5.Text = 'mm';

% Create mmLabel_6
app.mmLabel_6 = uilabel(app.UIFigure);
app.mmLabel_6.Position = [109 116 25 22];
app.mmLabel_6.Text = 'mm';

% Create mmLabel_7
app.mmLabel_7 = uilabel(app.UIFigure);
app.mmLabel_7.Position = [273 283 25 22];
app.mmLabel_7.Text = 'mm';

% Create mmLabel_8
app.mmLabel_8 = uilabel(app.UIFigure);
app.mmLabel_8.Position = [273 249 25 22];
app.mmLabel_8.Text = 'mm';

% Create mmLabel_9
app.mmLabel_9 = uilabel(app.UIFigure);
app.mmLabel_9.Position = [273 215 25 22];
app.mmLabel_9.Text = 'mm';

% Create L1EditFieldLabel
app.L1EditFieldLabel = uilabel(app.UIFigure);
app.L1EditFieldLabel.HorizontalAlignment = 'right';
app.L1EditFieldLabel.Position = [190 283 32 22];
app.L1EditFieldLabel.Text = 'L1 = ';

% Create L1EditField
app.L1EditField = uieditfield(app.UIFigure, 'numeric');
app.L1EditField.Tag = 'inLFus';
app.L1EditField.Position = [230 283 35 22];

% Create L2EditFieldLabel
app.L2EditFieldLabel = uilabel(app.UIFigure);
app.L2EditFieldLabel.HorizontalAlignment = 'right';
app.L2EditFieldLabel.Position = [190 249 32 22];
app.L2EditFieldLabel.Text = 'L2 = ';

% Create L2EditField
app.L2EditField = uieditfield(app.UIFigure, 'numeric');
app.L2EditField.Tag = 'inLFusIesit';
app.L2EditField.Position = [230 249 35 22];

% Create L3EditFieldLabel
app.L3EditFieldLabel = uilabel(app.UIFigure);
app.L3EditFieldLabel.HorizontalAlignment = 'right';
app.L3EditFieldLabel.Position = [190 212 32 22];
app.L3EditFieldLabel.Text = 'L3 = ';

% Create L3EditField
app.L3EditField = uieditfield(app.UIFigure, 'numeric');
app.L3EditField.Tag = 'inLDisc';
app.L3EditField.Position = [230 215 35 22];

% Create kgm3Label
app.kgm3Label = uilabel(app.UIFigure);
app.kgm3Label.Position = [274 147 43 22];
app.kgm3Label.Text = 'kg/m^3';

% Create kgm3Label_2
app.kgm3Label_2 = uilabel(app.UIFigure);
app.kgm3Label_2.Position = [273 110 43 22];
app.kgm3Label_2.Text = 'kg/m^3';

% Create Label_7
app.Label_7 = uilabel(app.UIFigure);
app.Label_7.HorizontalAlignment = 'right';
app.Label_7.Position = [190 147 32 22];
app.Label_7.Text = 'ρ1 = ';

% Create EditField_7
app.EditField_7 = uieditfield(app.UIFigure, 'numeric');
app.EditField_7.Tag = 'inRoDisc';
app.EditField_7.Position = [230 147 35 22];

% Create Label_8
app.Label_8 = uilabel(app.UIFigure);
app.Label_8.HorizontalAlignment = 'right';
app.Label_8.Position = [190 110 32 22];
app.Label_8.Text = 'ρ2 = ';

% Create EditField_8
app.EditField_8 = uieditfield(app.UIFigure, 'numeric');
app.EditField_8.Tag = 'inRoBucsa';
app.EditField_8.Position = [230 110 35 22];
% Create Image3
app.Image3 = uiimage(app.UIFigure);
app.Image3.ScaleMethod = 'fill';
app.Image3.Position = [339 120 247 206];
app.Image3.ImageSource = 'pozaAnsamblu.PNG';

% Create RezultatePanel
app.RezultatePanel = uipanel(app.UIFigure);
app.RezultatePanel.Title = 'Rezultate';
app.RezultatePanel.Position = [618 163 260 167];

% Create AnsambluLabel
app.AnsambluLabel = uilabel(app.RezultatePanel);
app.AnsambluLabel.Tag = 'numeRezultat';
app.AnsambluLabel.Position = [19 115 57 27];
app.AnsambluLabel.Text = 'Ansamblu';

% Create VolumLabel
app.VolumLabel = uilabel(app.RezultatePanel);
app.VolumLabel.Position = [31 86 52 22];
app.VolumLabel.Text = 'Volum = ';

% Create MasaLabel
app.MasaLabel = uilabel(app.RezultatePanel);
app.MasaLabel.Position = [31 54 48 22];
app.MasaLabel.Text = 'Masa = ';

% Create MomentLabel
app.MomentLabel = uilabel(app.RezultatePanel);
app.MomentLabel.Position = [31 19 63 22];
app.MomentLabel.Text = 'Moment = ';

% Create m3Label
app.m3Label = uilabel(app.RezultatePanel);
app.m3Label.Position = [198 86 27 22];
app.m3Label.Text = 'm^3';

% Create kgLabel
app.kgLabel = uilabel(app.RezultatePanel);
app.kgLabel.Position = [198 54 25 22];
app.kgLabel.Text = 'kg';
% Create NmLabel
app.NmLabel = uilabel(app.RezultatePanel);
app.NmLabel.Position = [198 19 29 22];
app.NmLabel.Text = 'N*m';

% Create EditField_9
app.EditField_9 = uieditfield(app.RezultatePanel, 'numeric');
app.EditField_9.Tag = 'outVolum';
app.EditField_9.Editable = 'off';
app.EditField_9.Position = [93 86 100 22];

% Create EditField_10
app.EditField_10 = uieditfield(app.RezultatePanel, 'numeric');
app.EditField_10.Tag = 'outMasa';
app.EditField_10.Editable = 'off';
app.EditField_10.Position = [93 49 100 22];

% Create EditField_11
app.EditField_11 = uieditfield(app.RezultatePanel, 'numeric');
app.EditField_11.Tag = 'outMoment';
app.EditField_11.Editable = 'off';
app.EditField_11.Position = [93 19 100 22];

% Create CalculeazavolumulmasasimomentuldeinertieButton
app.CalculeazavolumulmasasimomentuldeinertieButton = uibutton(app.UIFigure,
'push');
app.CalculeazavolumulmasasimomentuldeinertieButton.ButtonPushedFcn =
createCallbackFcn(app, @CalculeazavolumulmasasimomentuldeinertieButtonPushed,
true);
app.CalculeazavolumulmasasimomentuldeinertieButton.Tag = 'compute';
app.CalculeazavolumulmasasimomentuldeinertieButton.Position = [27.5 23 279 38];
app.CalculeazavolumulmasasimomentuldeinertieButton.Text = 'Calculeaza volumul,
masa si momentul de inertie';

% Create ResetButton
app.ResetButton = uibutton(app.UIFigure, 'push');
app.ResetButton.ButtonPushedFcn = createCallbackFcn(app, @ResetButtonPushed,
true);
app.ResetButton.Tag = 'reset';
app.ResetButton.Position = [413 23 100 38];
app.ResetButton.Text = 'Reset';

% Create CorpDropDownLabel
app.CorpDropDownLabel = uilabel(app.UIFigure);
app.CorpDropDownLabel.HorizontalAlignment = 'right';
app.CorpDropDownLabel.Position = [695 131 31 22];
app.CorpDropDownLabel.Text = 'Corp';

% Create CorpDropDown
app.CorpDropDown = uidropdown(app.UIFigure);
app.CorpDropDown.Items = {'Ansamblu', 'Arbore', 'Disc'};
app.CorpDropDown.ValueChangedFcn = createCallbackFcn(app,
@CorpDropDownValueChanged, true);
app.CorpDropDown.Tag = 'selectareCorp';
app.CorpDropDown.Position = [741 131 100 22];
app.CorpDropDown.Value = 'Ansamblu';

% Create gauriEditFieldLabel
app.gauriEditFieldLabel = uilabel(app.UIFigure);
app.gauriEditFieldLabel.HorizontalAlignment = 'right';
app.gauriEditFieldLabel.Position = [167 78 55 22];
app.gauriEditFieldLabel.Text = '# gauri = ';

% Create gauriEditField
app.gauriEditField = uieditfield(app.UIFigure, 'numeric');
app.gauriEditField.Tag = 'inNrGauri';
app.gauriEditField.Position = [230 78 35 22];

% Create mmLabel_12
app.mmLabel_12 = uilabel(app.UIFigure);
app.mmLabel_12.Position = [273 181 25 22];
app.mmLabel_12.Text = 'mm';

% Create L4EditFieldLabel
app.L4EditFieldLabel = uilabel(app.UIFigure);
app.L4EditFieldLabel.HorizontalAlignment = 'right';
app.L4EditFieldLabel.Position = [190 181 32 22];
app.L4EditFieldLabel.Text = 'L4 = ';

% Create L4EditField
app.L4EditField = uieditfield(app.UIFigure, 'numeric');
app.L4EditField.Tag = 'inLFusMic';
app.L4EditField.Position = [230 181 35 22];

% Create NutuLabel
app.NutulLabel = uilabel(app.UIFigure);
app.NutulLabel.Position = [133 414 131 22];
app.NutuLabel.Text = 'Nutu ';

% Create CalculatorvolummasasimomentalunuianasambluarborediscLabel
app.CalculatorvolummasasimomentalunuianasambluarborediscLabel =
uilabel(app.UIFigure);

app.CalculatorvolummasasimomentalunuianasambluarborediscLabel.HorizontalAlignmen
t = 'center';

app.CalculatorvolummasasimomentalunuianasambluarborediscLabel.FontSize = 19;

app.CalculatorvolummasasimomentalunuianasambluarborediscLabel.Position = [178.5
352 569 46];
app.CalculatorvolummasasimomentalunuianasambluarborediscLabel.Text =
'Calculator volum, masa si moment al unui anasamblu arbore-disc';

% 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 = App10

% 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

Poze:

Corp: Ansamblu
Corp: Arbore

Corp: Disc
Buton: Reset

You might also like