type visualiseringsapp2_1.mlapp
classdef visualiseringsapp2_1 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
UITable matlab.ui.control.Table
OsmoticdataresultsforallzonesLabel matlab.ui.control.Label
ReadresultsLabel matlab.ui.control.Label
Switch matlab.ui.control.Switch
UIAxes matlab.ui.control.UIAxes
end
properties (Access = public)
Callingapp
end
methods (Access = private)
% Code that executes after component creation
function startupFcn(app, app2, app3)
app.Callingapp = app3;
end
% Value changed function: Switch
function SwitchValueChanged(app, event)
value = app.Switch.Value;
if strcmpi(value,'on')
osmotic_data_table=readtable('Osmotic_data.xls', "Sheet", 1);
app.UITable.Data=osmotic_data_table;
app.UITable.ColumnName= osmotic_data_table.Properties.VariableNames;
x=table2array( osmotic_data_table(:,"Total_water_activity"));
y=table2array( osmotic_data_table(:,"Osmotic_pressure"));
plot(app.UIAxes,x,y)
end
for i = 1:app.Callingapp.antall_soner
if Osmotic_pressure(i)<100
effect='Not benefical';
elseif Osmotic_pressure(i)>=100&&Osmotic_pressure(i)<120
effect='Intermediate';
else
effect='Benefical';
end
end
app.UITable.Data=[osmotic_data_table effect];
end
end
% App initialization and construction
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure
app.UIFigure = uifigure;
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'UI Figure';
% Create UITable
app.UITable = uitable(app.UIFigure);
app.UITable.ColumnName = {'Column 1'; 'Column 2'; 'Column 3'; 'Column 4'};
app.UITable.RowName = {};
app.UITable.Position = [15 254 426 185];
% Create OsmoticdataresultsforallzonesLabel
app.OsmoticdataresultsforallzonesLabel = uilabel(app.UIFigure);
app.OsmoticdataresultsforallzonesLabel.BackgroundColor = [0 1 1];
app.OsmoticdataresultsforallzonesLabel.FontWeight = 'bold';
app.OsmoticdataresultsforallzonesLabel.Position = [15 450 426 22];
app.OsmoticdataresultsforallzonesLabel.Text = ' Osmotic data results for all zones';
% Create ReadresultsLabel
app.ReadresultsLabel = uilabel(app.UIFigure);
app.ReadresultsLabel.FontWeight = 'bold';
app.ReadresultsLabel.Position = [121 215 78 22];
app.ReadresultsLabel.Text = 'Read results';
% Create Switch
app.Switch = uiswitch(app.UIFigure, 'slider');
app.Switch.ValueChangedFcn = createCallbackFcn(app, @SwitchValueChanged, true);
app.Switch.Position = [242 217 45 20];
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, 'Total water activity versus osmotic pressure')
xlabel(app.UIAxes, 'Activity')
ylabel(app.UIAxes, 'Osmotic_ pressure')
app.UIAxes.YTickLabel = {'0'; '50'; '100'; '150'; '200'; '250'; '300'; '350'; '400'; '450'; '.500'; '1'};
app.UIAxes.XGrid = 'on';
app.UIAxes.YGrid = 'on';
app.UIAxes.Position = [15 10 426 185];
end
end
methods (Access = public)
% Construct app
function app = visualiseringsapp2_1(varargin)
% Create and configure components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
% Execute the startup function
runStartupFcn(app, @(app)startupFcn(app, varargin{:}))
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
I have a for loop in visualiseringsapp 2_1 , there is something wrong in it I think
I am gettin this error message when I run the app:
Error using visualiseringsapp2_1/startupFcn (line 23)
Not enough input arguments.
Error in visualiseringsapp2_1 (line 115)
runStartupFcn(app, @(app)startupFcn(app, varargin{:}))
Error in app3/DisplayallresultsButtonPushed (line 1855)
visualiseringsapp2_1(app)
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 335)
Error while evaluating Button PrivateButtonPushedFcn.
Dot indexing is not supported for variables of this type.
Error in visualiseringsapp2_1/SwitchValueChanged (line 42)
for i = 1:app.Callingapp.antall_soner
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 378)
Error while evaluating Switch PrivateValueChangedFcn.
.......
I have declared app2 as the input argument in my startup for visualiseringsapp2_1 because it is using the public property from app2 (called antall_soner), and the callingapp is app 3 . ( meaning the visualiseringsapp2_1 is called from app3), as you can see.