Error Plot App Designer

4 views (last 30 days)
Hello,
I am currently having problems to plot a graphic using appdesigner.
First, I wrote my code using the 2021b version and everything ran without problems. For some reasons I needed to change to the 2019b version and now my plots are simply not working anymore. My code is relativ simple, a plot comes when I check a box. For every box, a different column from a .csv file is selected as my Y -Axis. The X-Axis is always the first column of my .csv file. (C the 3rd, C1 the 4th and so on...)
The answer from matlab is: Error using plot - Not enough input arguments.
The .csv data I am using for debugging is a dummy file. With my previous matlab version I could use with every file.
Thanks on advance.
classdef All_Data < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
GridLayout matlab.ui.container.GridLayout
LeftPanel matlab.ui.container.Panel
DataSelectionLabel matlab.ui.control.Label
CheckBox matlab.ui.control.CheckBox
CheckBox_2 matlab.ui.control.CheckBox
CheckBox_4 matlab.ui.control.CheckBox
CheckBox_3 matlab.ui.control.CheckBox
CheckBox_5 matlab.ui.control.CheckBox
CheckBox_6 matlab.ui.control.CheckBox
CheckBox_7 matlab.ui.control.CheckBox
CheckBox_8 matlab.ui.control.CheckBox
CheckBox_15 matlab.ui.control.CheckBox
CheckBox_14 matlab.ui.control.CheckBox
CheckBox_13 matlab.ui.control.CheckBox
CheckBox_12 matlab.ui.control.CheckBox
CheckBox_11 matlab.ui.control.CheckBox
CheckBox_10 matlab.ui.control.CheckBox
CheckBox_9 matlab.ui.control.CheckBox
CheckBox_23 matlab.ui.control.CheckBox
CheckBox_22 matlab.ui.control.CheckBox
CheckBox_20 matlab.ui.control.CheckBox
CheckBox_21 matlab.ui.control.CheckBox
CheckBox_19 matlab.ui.control.CheckBox
CheckBox_18 matlab.ui.control.CheckBox
CheckBox_17 matlab.ui.control.CheckBox
CheckBox_16 matlab.ui.control.CheckBox
VDCCheckBox matlab.ui.control.CheckBox
PlotButton matlab.ui.control.StateButton
SensorSelectionLabel matlab.ui.control.Label
DataDropDownLabel matlab.ui.control.Label
DataDropDown matlab.ui.control.DropDown
ReadDataButton matlab.ui.control.StateButton
UITable matlab.ui.control.Table
RightPanel matlab.ui.container.Panel
UIAxes matlab.ui.control.UIAxes
CalculateButton matlab.ui.control.StateButton
PlotSensorWertxZeitLabel matlab.ui.control.Label
SensorCalculationDropDownLabel matlab.ui.control.Label
SensorCalculationDropDown matlab.ui.control.DropDown
MittelwertEditFieldLabel matlab.ui.control.Label
MittelwertEditField matlab.ui.control.NumericEditField
VarianzEditFieldLabel matlab.ui.control.Label
VarianzEditField matlab.ui.control.NumericEditField
WrzelVarianzEditFieldLabel matlab.ui.control.Label
WurzelVarianzEditField matlab.ui.control.NumericEditField
VonEditFieldLabel matlab.ui.control.Label
VonEditField matlab.ui.control.NumericEditField
BisEditFieldLabel matlab.ui.control.Label
BisEditField matlab.ui.control.NumericEditField
end
% Properties that correspond to apps with auto-reflow
properties (Access = private)
onePanelWidth = 576;
end
properties (Access = public)
A; % Description
end
methods (Access = public)
% function startupFcn(app)
% [pathname,dirname] = uigetfile('*.csv');
% fullpath = fullfile(dirname,pathname);
% fid = fopen(fullpath,'rt');
% datacell = textscan(fid,'%f');
% fclose(fid);
% a = datacell{1};
% clear fullpath fid datacell
% app.T = T;
% end
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
% [pathname,dirname] = uigetfile('*.csv');
% fullpath = fullfile(dirname,pathname);
% fid = fopen(fullpath,'rt');
% datacell = textscan(fid,'%f');
% fclose(fid);
% a = datacell{1};
% clear fullpath fid datacell
% T = readtable(pathname);
global A
A = uigetfile('*.csv');
app.A = A;
end
% Value changed function: CheckBox
function CheckBoxValueChanged(app, event)
value = app.CheckBox.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: PlotButton
function PlotButtonValueChanged(app, event)
%value = app.PlotButton.Value;
% T = readtable(app.A); %T = readtable("Test_Matlab.csv");
% if CCheckBoxValueChanged.Value
% YData = table2array(T(:,"C"));
% end
% plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: ReadDataButton
function ReadDataButtonValueChanged(app, event)
value = app.ReadDataButton.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
app.UITable.Data = T;
app.UITable.ColumnName = T.Properties.VariableNames;
end
% Value changed function: CheckBox_2
function CheckBox_2ValueChanged(app, event)
value = app.CheckBox_2.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C1"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_3
function CheckBox_3ValueChanged(app, event)
value = app.CheckBox_3.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C2"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_4
function CheckBox_4ValueChanged(app, event)
value = app.CheckBox_4.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C3"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_5
function CheckBox_5ValueChanged(app, event)
value = app.CheckBox_5.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C4"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_6
function CheckBox_6ValueChanged(app, event)
value = app.CheckBox_6.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C5"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_7
function CheckBox_7ValueChanged(app, event)
value = app.CheckBox_7.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C6"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_8
function CheckBox_8ValueChanged(app, event)
value = app.CheckBox_8.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C7"));
plot(app.UIAxes,T.Scan,YData);
end
% Callback function
function x108_C_CheckBox_2ValueChanged(app, event)
%value = app.x108_C_CheckBox_2.Value;
end
% Value changed function: CheckBox_9
function CheckBox_9ValueChanged(app, event)
value = app.CheckBox_9.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C8"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_10
function CheckBox_10ValueChanged(app, event)
value = app.CheckBox_10.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C9"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_11
function CheckBox_11ValueChanged(app, event)
value = app.CheckBox_11.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C10"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_12
function CheckBox_12ValueChanged(app, event)
value = app.CheckBox_12.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C11"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_13
function CheckBox_13ValueChanged(app, event)
value = app.CheckBox_13.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C12"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_14
function CheckBox_14ValueChanged(app, event)
value = app.CheckBox_14.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C13"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_15
function CheckBox_15ValueChanged(app, event)
value = app.CheckBox_15.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C14"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_16
function CheckBox_16ValueChanged(app, event)
value = app.CheckBox_16.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C15"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_17
function CheckBox_17ValueChanged(app, event)
value = app.CheckBox_17.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C16"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_18
function CheckBox_18ValueChanged(app, event)
value = app.CheckBox_18.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C17"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_19
function CheckBox_19ValueChanged(app, event)
value = app.CheckBox_19.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C18"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_20
function CheckBox_20ValueChanged(app, event)
value = app.CheckBox_20.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C19"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_21
function CheckBox_21ValueChanged(app, event)
value = app.CheckBox_21.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C20"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_22
function CheckBox_22ValueChanged(app, event)
value = app.CheckBox_22.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C21"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: CheckBox_23
function CheckBox_23ValueChanged(app, event)
value = app.CheckBox_23.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C22"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: VDCCheckBox
function VDCCheckBoxValueChanged(app, event)
value = app.VDCCheckBox.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
YData = table2array(T(:,"C23"));
plot(app.UIAxes,T.Scan,YData);
end
% Value changed function: DataDropDown
function DataDropDownValueChanged(app, event)
value = app.DataDropDown.Value;
end
% Value changed function: CalculateButton
function CalculateButtonValueChanged(app, event)
value = app.CalculateButton.Value;
von = app.VonEditField.Value;
bis = app.BisEditField.Value;
T = readtable(app.A); %T = readtable("Test_Matlab.csv");
if (app.SensorCalculationDropDown.Value == "C")
YData = table2array(T(:,"C"));
M_101 = mean(YData(von:bis));
V_101 = var(YData(von:bis));
W_V_101 = sqrt(V_101);
app.MittelwertEditField.Value = M_101;
app.VarianzEditField.Value = V_101;
app.WurzelVarianzEditField.Value = W_V_101;
end
if (app.SensorCalculationDropDown.Value == "C1")
YData = table2array(T(:,"C1"));
M_102 = mean(YData(von:bis));
V_102 = var(YData(von:bis));
W_V_102 = sqrt(V_102);
app.MittelwertEditField.Value = M_102;
app.VarianzEditField.Value = V_102;
app.WurzelVarianzEditField.Value = W_V_102;
end
if (app.SensorCalculationDropDown.Value == "C2")
YData = table2array(T(:,"C2"));
bereich = unique(YData(von:bis));
bereich = unique(bereich);
M_103 = mean(bereich);
V_103 = var(bereich);
W_V_103 = sqrt(V_103);
app.MittelwertEditField.Value = M_103;
app.VarianzEditField.Value = V_103;
app.WurzelVarianzEditField.Value = W_V_103;
end
if (app.SensorCalculationDropDown.Value == "C3")
YData = table2array(T(:,"C3"));
M_104 = mean(YData(von:bis));
V_104 = var(YData(von:bis));
W_V_104 = sqrt(V_104);
app.MittelwertEditField.Value = M_104;
app.VarianzEditField.Value = V_104;
app.WurzelVarianzEditField.Value = W_V_104;
end
if (app.SensorCalculationDropDown.Value == "C4")
YData = table2array(T(:,"C4"));
M_105 = mean(YData(von:bis));
V_105 = var(YData(von:bis));
W_V_105 = sqrt(V_105);
app.MittelwertEditField.Value = M_105;
app.VarianzEditField.Value = V_105;
app.WurzelVarianzEditField.Value = W_V_105;
end
if (app.SensorCalculationDropDown.Value == "C5")
YData = table2array(T(:,"C5"));
M_106 = mean(YData(von:bis));
V_106 = var(YData(von:bis));
W_V_106 = sqrt(V_106);
app.MittelwertEditField.Value = M_106;
app.VarianzEditField.Value = V_106;
app.WurzelVarianzEditField.Value = W_V_106;
end
if (app.SensorCalculationDropDown.Value == "C6")
YData = table2array(T(:,"C6"));
M_107 = mean(YData(von:bis));
V_107 = var(YData(von:bis));
W_V_107 = sqrt(V_107);
app.MittelwertEditField.Value = M_107;
app.VarianzEditField.Value = V_107;
app.WurzelVarianzEditField.Value = W_V_107;
end
if (app.SensorCalculationDropDown.Value == "C7")
YData = table2array(T(:,"C7"));
M_108 = mean(YData(von:bis));
V_108 = var(YData(von:bis));
W_V_108 = sqrt(V_108);
app.MittelwertEditField.Value = M_108;
app.VarianzEditField.Value = V_108;
app.WurzelVarianzEditField.Value = W_V_108;
end
if (app.SensorCalculationDropDown.Value == "C8")
YData = table2array(T(:,"C8"));
M_109 = mean(YData(von:bis));
V_109 = var(YData(von:bis));
W_V_109 = sqrt(V_109);
app.MittelwertEditField.Value = M_109;
app.VarianzEditField.Value = V_109;
app.WurzelVarianzEditField.Value = W_V_109;
end
if (app.SensorCalculationDropDown.Value == "C9")
YData = table2array(T(:,"C9"));
M_110 = mean(YData(von:bis));
V_110 = var(YData(von:bis));
W_V_110 = sqrt(V_110);
app.MittelwertEditField.Value = M_110;
app.VarianzEditField.Value = V_110;
app.WurzelVarianzEditField.Value = W_V_110;
end
if (app.SensorCalculationDropDown.Value == "C10")
YData = table2array(T(:,"C10"));
M_111 = mean(YData(von:bis));
V_111 = var(YData(von:bis));
W_V_111 = sqrt(V_111);
app.MittelwertEditField.Value = M_111;
app.VarianzEditField.Value = V_111;
app.WurzelVarianzEditField.Value = W_V_111;
end
if (app.SensorCalculationDropDown.Value == "C11")
YData = table2array(T(:,"C11"));
M_112 = mean(YData(von:bis));
V_112 = var(YData(von:bis));
W_V_112 = sqrt(V_112);
app.MittelwertEditField.Value = M_112;
app.VarianzEditField.Value = V_112;
app.WurzelVarianzEditField.Value = W_V_112;
end
if (app.SensorCalculationDropDown.Value == "C12")
YData = table2array(T(:,"C12"));
M_113 = mean(YData(von:bis));
V_113 = var(YData(von:bis));
W_V_113 = sqrt(V_113);
app.MittelwertEditField.Value = M_113;
app.VarianzEditField.Value = V_113;
app.WurzelVarianzEditField.Value = W_V_113;
end
if (app.SensorCalculationDropDown.Value == "C13")
YData = table2array(T(:,"C13"));
M_201 = mean(YData(von:bis));
V_201 = var(YData(von:bis));
W_V_201 = sqrt(V_113);
app.MittelwertEditField.Value = M_201;
app.VarianzEditField.Value = V_201;
app.WurzelVarianzEditField.Value = W_V_201;
end
if (app.SensorCalculationDropDown.Value == "C14")
YData = table2array(T(:,"C14"));
M_202 = mean(YData(von:bis));
V_202 = var(YData(von:bis));
W_V_202 = sqrt(V_202);
app.MittelwertEditField.Value = M_202;
app.VarianzEditField.Value = V_202;
app.WurzelVarianzEditField.Value = W_V_202;
end
if (app.SensorCalculationDropDown.Value == "C15")
YData = table2array(T(:,"C15"));
M_203 = mean(YData(von:bis));
V_203 = var(YData(von:bis));
W_V_203 = sqrt(V_203);
app.MittelwertEditField.Value = M_203;
app.VarianzEditField.Value = V_203;
app.WurzelVarianzEditField.Value = W_V_203;
end
if (app.SensorCalculationDropDown.Value == "C16")
YData = table2array(T(:,"C16"));
M_204 = mean(YData(von:bis));
V_204 = var(YData(von:bis));
W_V_204 = sqrt(V_204);
app.MittelwertEditField.Value = M_204;
app.VarianzEditField.Value = V_204;
app.WurzelVarianzEditField.Value = W_V_204;
end
if (app.SensorCalculationDropDown.Value == "C17")
YData = table2array(T(:,"C17"));
M_205 = mean(YData(von:bis));
V_205 = var(YData(von:bis));
W_V_205 = sqrt(V_205);
app.MittelwertEditField.Value = M_205;
app.VarianzEditField.Value = V_205;
app.WurzelVarianzEditField.Value = W_V_205;
end
if (app.SensorCalculationDropDown.Value == "C18")
YData = table2array(T(:,"C18"));
M_206 = mean(YData(von:bis));
V_206 = var(YData(von:bis));
W_V_206 = sqrt(V_206);
app.MittelwertEditField.Value = M_206;
app.VarianzEditField.Value = V_206;
app.WurzelVarianzEditField.Value = W_V_206;
end
if (app.SensorCalculationDropDown.Value == "C19")
YData = table2array(T(:,"C19"));
M_207 = mean(YData(von:bis));
V_207 = var(YData(von:bis));
W_V_207 = sqrt(V_207);
app.MittelwertEditField.Value = M_207;
app.VarianzEditField.Value = V_207;
app.WurzelVarianzEditField.Value = W_V_207;
end
if (app.SensorCalculationDropDown.Value == "C20")
YData = table2array(T(:,"C20"));
M_208 = mean(YData(von:bis));
V_208 = var(YData(von:bis));
W_V_208 = sqrt(V_208);
app.MittelwertEditField.Value = M_208;
app.VarianzEditField.Value = V_208;
app.WurzelVarianzEditField.Value = W_V_208;
end
if (app.SensorCalculationDropDown.Value == "C21")
YData = table2array(T(:,"C21"));
M_209 = mean(YData(von:bis));
V_209 = var(YData(von:bis));
W_V_209 = sqrt(V_209);
app.MittelwertEditField.Value = M_209;
app.VarianzEditField.Value = V_209;
app.WurzelVarianzEditField.Value = W_V_209;
end
if (app.SensorCalculationDropDown.Value == "C22")
YData = table2array(T(:,"C22"));
M_210 = mean(YData(von:bis));
V_210 = var(YData(von:bis));
W_V_210 = sqrt(V_210);
app.MittelwertEditField.Value = M_210;
app.VarianzEditField.Value = V_210;
app.WurzelVarianzEditField.Value = W_V_210;
end
if (app.SensorCalculationDropDown.Value == "C23")
YData = table2array(T(:,"C23"));
M_212 = mean(YData(von:bis));
V_212 = var(YData(von:bis));
W_V_212 = sqrt(V_212);
app.MittelwertEditField.Value = M_212;
app.VarianzEditField.Value = V_212;
app.WurzelVarianzEditField.Value = W_V_212;
end
end
% Value changed function: SensorCalculationDropDown
function SensorCalculationDropDownValueChanged(app, event)
value = app.SensorCalculationDropDown.Value;
end
% Changes arrangement of the app based on UIFigure width
function updateAppLayout(app, event)
currentFigureWidth = app.UIFigure.Position(3);
if(currentFigureWidth <= app.onePanelWidth)
% Change to a 2x1 grid
app.GridLayout.RowHeight = {678, 678};
app.GridLayout.ColumnWidth = {'1x'};
app.RightPanel.Layout.Row = 2;
app.RightPanel.Layout.Column = 1;
else
% Change to a 1x2 grid
app.GridLayout.RowHeight = {'1x'};
app.GridLayout.ColumnWidth = {216, '1x'};
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
end
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.AutoResizeChildren = 'off';
app.UIFigure.Position = [100 100 1026 678];
app.UIFigure.Name = 'MATLAB App';
app.UIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);
% Create GridLayout
app.GridLayout = uigridlayout(app.UIFigure);
app.GridLayout.ColumnWidth = {216, '1x'};
app.GridLayout.RowHeight = {'1x'};
app.GridLayout.ColumnSpacing = 0;
app.GridLayout.RowSpacing = 0;
app.GridLayout.Padding = [0 0 0 0];
app.GridLayout.Scrollable = 'on';
% Create LeftPanel
app.LeftPanel = uipanel(app.GridLayout);
app.LeftPanel.Layout.Row = 1;
app.LeftPanel.Layout.Column = 1;
% Create DataSelectionLabel
app.DataSelectionLabel = uilabel(app.LeftPanel);
app.DataSelectionLabel.Position = [65 655 84 22];
app.DataSelectionLabel.Text = 'Data Selection';
% Create CheckBox
app.CheckBox = uicheckbox(app.LeftPanel);
app.CheckBox.ValueChangedFcn = createCallbackFcn(app, @CheckBoxValueChanged, true);
app.CheckBox.Text = '101';
app.CheckBox.Position = [7 472 42 22];
% Create CheckBox_2
app.CheckBox_2 = uicheckbox(app.LeftPanel);
app.CheckBox_2.ValueChangedFcn = createCallbackFcn(app, @CheckBox_2ValueChanged, true);
app.CheckBox_2.Text = '102';
app.CheckBox_2.Position = [7 451 42 22];
% Create CheckBox_4
app.CheckBox_4 = uicheckbox(app.LeftPanel);
app.CheckBox_4.ValueChangedFcn = createCallbackFcn(app, @CheckBox_4ValueChanged, true);
app.CheckBox_4.Text = '104';
app.CheckBox_4.Position = [7 409 42 22];
% Create CheckBox_3
app.CheckBox_3 = uicheckbox(app.LeftPanel);
app.CheckBox_3.ValueChangedFcn = createCallbackFcn(app, @CheckBox_3ValueChanged, true);
app.CheckBox_3.Text = '103';
app.CheckBox_3.Position = [7 430 42 22];
% Create CheckBox_5
app.CheckBox_5 = uicheckbox(app.LeftPanel);
app.CheckBox_5.ValueChangedFcn = createCallbackFcn(app, @CheckBox_5ValueChanged, true);
app.CheckBox_5.Text = '105';
app.CheckBox_5.Position = [7 388 42 22];
% Create CheckBox_6
app.CheckBox_6 = uicheckbox(app.LeftPanel);
app.CheckBox_6.ValueChangedFcn = createCallbackFcn(app, @CheckBox_6ValueChanged, true);
app.CheckBox_6.Text = '106';
app.CheckBox_6.Position = [7 367 42 22];
% Create CheckBox_7
app.CheckBox_7 = uicheckbox(app.LeftPanel);
app.CheckBox_7.ValueChangedFcn = createCallbackFcn(app, @CheckBox_7ValueChanged, true);
app.CheckBox_7.Text = '107';
app.CheckBox_7.Position = [7 346 42 22];
% Create CheckBox_8
app.CheckBox_8 = uicheckbox(app.LeftPanel);
app.CheckBox_8.ValueChangedFcn = createCallbackFcn(app, @CheckBox_8ValueChanged, true);
app.CheckBox_8.Text = '108';
app.CheckBox_8.Position = [7 325 42 22];
% Create CheckBox_15
app.CheckBox_15 = uicheckbox(app.LeftPanel);
app.CheckBox_15.ValueChangedFcn = createCallbackFcn(app, @CheckBox_15ValueChanged, true);
app.CheckBox_15.Text = '202';
app.CheckBox_15.Position = [124 451 42 22];
% Create CheckBox_14
app.CheckBox_14 = uicheckbox(app.LeftPanel);
app.CheckBox_14.ValueChangedFcn = createCallbackFcn(app, @CheckBox_14ValueChanged, true);
app.CheckBox_14.Text = '201';
app.CheckBox_14.Position = [124 472 42 22];
% Create CheckBox_13
app.CheckBox_13 = uicheckbox(app.LeftPanel);
app.CheckBox_13.ValueChangedFcn = createCallbackFcn(app, @CheckBox_13ValueChanged, true);
app.CheckBox_13.Text = '113';
app.CheckBox_13.Position = [7 220 41 22];
% Create CheckBox_12
app.CheckBox_12 = uicheckbox(app.LeftPanel);
app.CheckBox_12.ValueChangedFcn = createCallbackFcn(app, @CheckBox_12ValueChanged, true);
app.CheckBox_12.Text = '112';
app.CheckBox_12.Position = [7 241 41 22];
% Create CheckBox_11
app.CheckBox_11 = uicheckbox(app.LeftPanel);
app.CheckBox_11.ValueChangedFcn = createCallbackFcn(app, @CheckBox_11ValueChanged, true);
app.CheckBox_11.Text = '111';
app.CheckBox_11.Position = [8 262 40 22];
% Create CheckBox_10
app.CheckBox_10 = uicheckbox(app.LeftPanel);
app.CheckBox_10.ValueChangedFcn = createCallbackFcn(app, @CheckBox_10ValueChanged, true);
app.CheckBox_10.Text = '110';
app.CheckBox_10.Position = [7 283 41 22];
% Create CheckBox_9
app.CheckBox_9 = uicheckbox(app.LeftPanel);
app.CheckBox_9.ValueChangedFcn = createCallbackFcn(app, @CheckBox_9ValueChanged, true);
app.CheckBox_9.Text = '109';
app.CheckBox_9.Position = [7 304 42 22];
% Create CheckBox_23
app.CheckBox_23 = uicheckbox(app.LeftPanel);
app.CheckBox_23.ValueChangedFcn = createCallbackFcn(app, @CheckBox_23ValueChanged, true);
app.CheckBox_23.Text = '210';
app.CheckBox_23.Position = [124 283 42 22];
% Create CheckBox_22
app.CheckBox_22 = uicheckbox(app.LeftPanel);
app.CheckBox_22.ValueChangedFcn = createCallbackFcn(app, @CheckBox_22ValueChanged, true);
app.CheckBox_22.Text = '209';
app.CheckBox_22.Position = [124 304 42 22];
% Create CheckBox_20
app.CheckBox_20 = uicheckbox(app.LeftPanel);
app.CheckBox_20.ValueChangedFcn = createCallbackFcn(app, @CheckBox_20ValueChanged, true);
app.CheckBox_20.Text = '207';
app.CheckBox_20.Position = [124 346 42 22];
% Create CheckBox_21
app.CheckBox_21 = uicheckbox(app.LeftPanel);
app.CheckBox_21.ValueChangedFcn = createCallbackFcn(app, @CheckBox_21ValueChanged, true);
app.CheckBox_21.Text = '208';
app.CheckBox_21.Position = [124 325 42 22];
% Create CheckBox_19
app.CheckBox_19 = uicheckbox(app.LeftPanel);
app.CheckBox_19.ValueChangedFcn = createCallbackFcn(app, @CheckBox_19ValueChanged, true);
app.CheckBox_19.Text = '206';
app.CheckBox_19.Position = [124 367 42 22];
% Create CheckBox_18
app.CheckBox_18 = uicheckbox(app.LeftPanel);
app.CheckBox_18.ValueChangedFcn = createCallbackFcn(app, @CheckBox_18ValueChanged, true);
app.CheckBox_18.Text = '205';
app.CheckBox_18.Position = [124 388 42 22];
% Create CheckBox_17
app.CheckBox_17 = uicheckbox(app.LeftPanel);
app.CheckBox_17.ValueChangedFcn = createCallbackFcn(app, @CheckBox_17ValueChanged, true);
app.CheckBox_17.Text = '204';
app.CheckBox_17.Position = [124 409 42 22];
% Create CheckBox_16
app.CheckBox_16 = uicheckbox(app.LeftPanel);
app.CheckBox_16.ValueChangedFcn = createCallbackFcn(app, @CheckBox_16ValueChanged, true);
app.CheckBox_16.Text = '203';
app.CheckBox_16.Position = [124 430 42 22];
% Create VDCCheckBox
app.VDCCheckBox = uicheckbox(app.LeftPanel);
app.VDCCheckBox.ValueChangedFcn = createCallbackFcn(app, @VDCCheckBoxValueChanged, true);
app.VDCCheckBox.Text = '212(VDC)';
app.VDCCheckBox.Position = [124 262 75 22];
% Create PlotButton
app.PlotButton = uibutton(app.LeftPanel, 'state');
app.PlotButton.ValueChangedFcn = createCallbackFcn(app, @PlotButtonValueChanged, true);
app.PlotButton.Text = 'Plot';
app.PlotButton.Position = [49 144 100 22];
% Create SensorSelectionLabel
app.SensorSelectionLabel = uilabel(app.LeftPanel);
app.SensorSelectionLabel.Position = [65 493 96 22];
app.SensorSelectionLabel.Text = 'Sensor Selection';
% Create DataDropDownLabel
app.DataDropDownLabel = uilabel(app.LeftPanel);
app.DataDropDownLabel.HorizontalAlignment = 'right';
app.DataDropDownLabel.Position = [26 595 31 22];
app.DataDropDownLabel.Text = 'Data';
% Create DataDropDown
app.DataDropDown = uidropdown(app.LeftPanel);
app.DataDropDown.ValueChangedFcn = createCallbackFcn(app, @DataDropDownValueChanged, true);
app.DataDropDown.Position = [72 595 100 22];
% Create ReadDataButton
app.ReadDataButton = uibutton(app.LeftPanel, 'state');
app.ReadDataButton.ValueChangedFcn = createCallbackFcn(app, @ReadDataButtonValueChanged, true);
app.ReadDataButton.Text = 'Read Data';
app.ReadDataButton.Position = [49 552 100 22];
% Create UITable
app.UITable = uitable(app.LeftPanel);
app.UITable.ColumnName = {'Column 1'; 'Column 2'; 'Column 3'; 'Column 4'};
app.UITable.RowName = {};
app.UITable.Position = [28 7 144 84];
% Create RightPanel
app.RightPanel = uipanel(app.GridLayout);
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
% Create UIAxes
app.UIAxes = uiaxes(app.RightPanel);
title(app.UIAxes, 'plot sensor wert x Zeit')
xlabel(app.UIAxes, 'Zeit')
ylabel(app.UIAxes, 'Sensor Value')
zlabel(app.UIAxes, 'Z')
app.UIAxes.XGrid = 'on';
app.UIAxes.YGrid = 'on';
app.UIAxes.Position = [7 155 725 501];
% Create CalculateButton
app.CalculateButton = uibutton(app.RightPanel, 'state');
app.CalculateButton.ValueChangedFcn = createCallbackFcn(app, @CalculateButtonValueChanged, true);
app.CalculateButton.Text = 'Calculate';
app.CalculateButton.Position = [347 67 100 22];
% Create PlotSensorWertxZeitLabel
app.PlotSensorWertxZeitLabel = uilabel(app.RightPanel);
app.PlotSensorWertxZeitLabel.Position = [384 655 129 22];
app.PlotSensorWertxZeitLabel.Text = 'Plot Sensor Wert x Zeit';
% Create SensorCalculationDropDownLabel
app.SensorCalculationDropDownLabel = uilabel(app.RightPanel);
app.SensorCalculationDropDownLabel.HorizontalAlignment = 'right';
app.SensorCalculationDropDownLabel.Position = [7 109 106 22];
app.SensorCalculationDropDownLabel.Text = 'Sensor Calculation';
% Create SensorCalculationDropDown
app.SensorCalculationDropDown = uidropdown(app.RightPanel);
app.SensorCalculationDropDown.Items = {'C', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10', 'C11', 'C12', 'C13', 'C14', 'C15', 'C16', 'C17', 'C18', 'C19', 'C20', 'C21', 'C22', 'C23'};
app.SensorCalculationDropDown.ValueChangedFcn = createCallbackFcn(app, @SensorCalculationDropDownValueChanged, true);
app.SensorCalculationDropDown.Position = [128 109 100 22];
app.SensorCalculationDropDown.Value = 'C';
% Create MittelwertEditFieldLabel
app.MittelwertEditFieldLabel = uilabel(app.RightPanel);
app.MittelwertEditFieldLabel.HorizontalAlignment = 'right';
app.MittelwertEditFieldLabel.Position = [17 16 57 22];
app.MittelwertEditFieldLabel.Text = 'Mittelwert';
% Create MittelwertEditField
app.MittelwertEditField = uieditfield(app.RightPanel, 'numeric');
app.MittelwertEditField.Position = [89 16 139 22];
% Create VarianzEditFieldLabel
app.VarianzEditFieldLabel = uilabel(app.RightPanel);
app.VarianzEditFieldLabel.HorizontalAlignment = 'right';
app.VarianzEditFieldLabel.Position = [227 17 45 22];
app.VarianzEditFieldLabel.Text = 'Varianz';
% Create VarianzEditField
app.VarianzEditField = uieditfield(app.RightPanel, 'numeric');
app.VarianzEditField.Position = [287 17 134 22];
% Create WrzelVarianzEditFieldLabel
app.WrzelVarianzEditFieldLabel = uilabel(app.RightPanel);
app.WrzelVarianzEditFieldLabel.HorizontalAlignment = 'right';
app.WrzelVarianzEditFieldLabel.Position = [418 17 86 22];
app.WrzelVarianzEditFieldLabel.Text = 'Würzel Varianz';
% Create WurzelVarianzEditField
app.WurzelVarianzEditField = uieditfield(app.RightPanel, 'numeric');
app.WurzelVarianzEditField.Position = [519 17 257 22];
% Create VonEditFieldLabel
app.VonEditFieldLabel = uilabel(app.RightPanel);
app.VonEditFieldLabel.HorizontalAlignment = 'right';
app.VonEditFieldLabel.Position = [7 67 26 22];
app.VonEditFieldLabel.Text = 'Von';
% Create VonEditField
app.VonEditField = uieditfield(app.RightPanel, 'numeric');
app.VonEditField.Position = [48 67 100 22];
% Create BisEditFieldLabel
app.BisEditFieldLabel = uilabel(app.RightPanel);
app.BisEditFieldLabel.HorizontalAlignment = 'right';
app.BisEditFieldLabel.Position = [168 67 25 22];
app.BisEditFieldLabel.Text = 'Bis';
% Create BisEditField
app.BisEditField = uieditfield(app.RightPanel, 'numeric');
app.BisEditField.Position = [208 67 100 22];
% 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 = All_Data
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @startupFcn)
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

Accepted Answer

Cris LaPierre
Cris LaPierre on 12 Jan 2022
Edited: Cris LaPierre on 13 Jan 2022
First off, check out the Access Data in Tables page. There is no need to do this:
YData = table2array(T(:,"C"));
You can simply do this:
YData = T.C;
I would also suggest using app properties to share data between callbacks (e.g. T). I would probably use a startupFcn to load the spreadsheet so that you don't have to keep reloading it in every plotting callback function.
I wonder if the issue isn't that your file is not loading. Unless it is in the same folder as your app, or in a folder on your MATLAB path, it isn't. What if you change the definition for A to be
[file,path] = uigetfile('*.csv');
app.A = fullfile(path,file);
% load the file once here.
app.T = readtable(app.A);
And delete the declaration of A being global in your startup function. You don't need it.
Now your callbacks can be simplified to this.
% Value changed function: CheckBox_2
function CheckBox_2ValueChanged(app, event)
YData = app.T.C1;
plot(app.UIAxes,app.T.Scan,YData);
end
Just the standard warning - none of this has been tested.
  1 Comment
Jelena Petrovic
Jelena Petrovic on 13 Jan 2022
Dear Mr. LaPierre,
Many thanks for your answer.
You were right about the issue, it was really about the data I was using. I will also perform the changes you suggested me, now I realize I could've done much simplier.

Sign in to comment.

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!