Create MATLAB GUI that compares the output of MATLAB regression and interpolation capabilities. The GUI accepts an input data vector pair and performs a regression analysis and a data interpolation...

1 answer below »
Create MATLAB GUI that compares the output of MATLAB regression and interpolation capabilities. The GUI accepts an input data vector pair and performs a regression analysis and a data interpolation based on one of the three methods given in the listbox.
Answered Same DayApr 27, 2021

Answer To: Create MATLAB GUI that compares the output of MATLAB regression and interpolation capabilities. The...

Kshitij answered on Apr 28 2021
137 Votes
GUI/App.mlapp
[Content_Types].xml

_rels/.rels

metadata/appScreenshot.png
appdesigner/appModel.mat
matlab/document.xml
classdef App < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
RegressionOrderSlider matlab.ui.control.Slider
RegressionOrderSliderLabel matlab.ui.control.Label
InterpolationMethodListBox matlab.ui.co
ntrol.ListBox
InterpolationMethodListBoxLabel matlab.ui.control.Label
EnableDataSaveCheckBox matlab.ui.control.CheckBox
CalculateDataButton matlab.ui.control.Button
Input2EditField matlab.ui.control.EditField
Input2EditFieldLabel matlab.ui.control.Label
Input1EditField matlab.ui.control.EditField
Input1EditFieldLabel matlab.ui.control.Label
UIAxes matlab.ui.control.UIAxes
end
% Callbacks that handle component events
methods (Access = private)
% Value changed function: Input1EditField
function Input1EditFieldValueChanged(app, event)
% value = app.Input1EditField.Value;
Xtest1 = app.Input1EditField.Value;
app.RegressionOrderSlider.Limits=[0,numel(Xtest1)-1];
end
% Button pushed function: CalculateDataButton
function CalculateDataButtonPushed(app, event)
Xtest1 = app.Input1EditField.Value;
Ytest = app.Input2EditField.Value;
Xtest1 = str2num(Xtest1);
Ytest = str2num(Ytest);
Xtest = linspace(min(Xtest1),max(Xtest1),100);
YtestInt = interp1(Xtest1,Ytest,Xtest,app.InterpolationMethodListBox.Value);
P=polyfit(Xtest,YtestInt,round(app.RegressionOrderSlider.Value));
YtestReg = polyval(P,Xtest);
if app.EnableDataSaveCheckBox.Value==1
assignin('base','Xtest',Xtest);
assignin('base','regCoeffs',P);
assignin('base','yTestInt',YtestInt);
assignin('base','yTestReg',YtestReg);
end
plot(app.UIAxes,Xtest1,Ytest,'or',Xtest,YtestInt,'--b',Xtest,YtestReg,'.g')
end
% Value changed function: Input2EditField
function Input2EditFieldValueChanged(app, event)
%value = app.Input2EditField.Value;
Xtest1 = app.Input1EditField.Value;
app.RegressionOrderSlider.Limits=[0,numel(Xtest1)-1];
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 = 'MATLAB App';
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, 'GUI Analysis System')
xlabel(app.UIAxes, 'X')
ylabel(app.UIAxes, 'Y')
zlabel(app.UIAxes, 'Z')
app.UIAxes.FontSize = 12;
app.UIAxes.Position = [206 60 413 366];
% Create Input1EditFieldLabel
app.Input1EditFieldLabel = uilabel(app.UIFigure);
app.Input1EditFieldLabel.HorizontalAlignment = 'right';
app.Input1EditFieldLabel.FontWeight = 'bold';
app.Input1EditFieldLabel.Position = [88 410 45 22];
app.Input1EditFieldLabel.Text = 'Input 1';
% Create Input1EditField
app.Input1EditField = uieditfield(app.UIFigure, 'text');
app.Input1EditField.ValueChangedFcn = createCallbackFcn(app, @Input1EditFieldValueChanged, true);
app.Input1EditField.FontWeight = 'bold';
app.Input1EditField.Position = [62 381 100 22];
% Create Input2EditFieldLabel
app.Input2EditFieldLabel = uilabel(app.UIFigure);
app.Input2EditFieldLabel.HorizontalAlignment = 'right';
app.Input2EditFieldLabel.FontWeight = 'bold';
app.Input2EditFieldLabel.Position = [88 336 45 22];
app.Input2EditFieldLabel.Text = 'Input 2';
% Create Input2EditField
app.Input2EditField = uieditfield(app.UIFigure, 'text');
app.Input2EditField.ValueChangedFcn = createCallbackFcn(app, @Input2EditFieldValueChanged, true);
app.Input2EditField.FontWeight = 'bold';
app.Input2EditField.Position = [62 304 100 22];
% Create CalculateDataButton
app.CalculateDataButton = uibutton(app.UIFigure, 'push');
app.CalculateDataButton.ButtonPushedFcn = createCallbackFcn(app, @CalculateDataButtonPushed, true);
app.CalculateDataButton.Position = [319 13 186 34];
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here