i have uploaded a table. how can i read it to a table? my next step is to do a table2array. Problem is it that i cant find out where should i begin to

2 views (last 30 days)
classdef SToRM_20211208 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
Label matlab.ui.control.Label
SToRMLabel matlab.ui.control.Label
SimulationdesTorsionsverhaltenseinesRotorstrangsmitMATLABLabel matlab.ui.control.Label
CalculatefeigButton matlab.ui.control.Button
UITable matlab.ui.control.Table
CheckDataButton matlab.ui.control.Button
UploadTableButton matlab.ui.control.Button
UIAxes matlab.ui.control.UIAxes
end
properties (Access = public)
%Variables
data; %Enthält die eingelesenen Daten, die den Körper beschreiben
error;
%Function Handler
DataImport = @function_DataImport; %Funktion zum Import der DataMatrix
DataCheck = @function_DataCheck;
end
% methods (Access = private)
%
% function check(app)
%
% error = app.DataCheck;
%
% % app.ErrorOutputTextfield.Value = Error; %Add Error-Output field here
%
% end
% end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
clc
%Diabling all Buttons
app.CheckDataButton.Enable = 'off';
app.CalculatefeigButton.Enable = 'off';
app.UITable.Enable = 'off';
end
% Button pushed function: UploadTableButton
function UploadTableButtonPushed(app, event)
dataMatrix = DataImport;
app.UITable.Data = dataMatrix;
app.data = dataMatrix;
%Enabling all Buttons
app.CheckDataButton.Enable = 'on';
app.CalculatefeigButton.Enable = 'on';
app.UITable.Enable = 'on';
end
% Display data changed function: UITable
function UITableDisplayDataChanged(app, event)
newDisplayData = app.UITable.DisplayData;
end
% Button pushed function: CheckDataButton
function CheckDataButtonPushed(app, event)
data = app.data
app.error = DataCheck(data);
error = app.error
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 963 714];
app.UIFigure.Name = 'MATLAB App';
% Create UIAxes
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, 'Title')
xlabel(app.UIAxes, 'X')
ylabel(app.UIAxes, 'Y')
zlabel(app.UIAxes, 'Z')
app.UIAxes.Position = [201 369 734 266];
% Create UploadTableButton
app.UploadTableButton = uibutton(app.UIFigure, 'push');
app.UploadTableButton.ButtonPushedFcn = createCallbackFcn(app, @UploadTableButtonPushed, true);
app.UploadTableButton.Position = [28 571 100 22];
app.UploadTableButton.Text = 'Upload Table';
% Create CheckDataButton
app.CheckDataButton = uibutton(app.UIFigure, 'push');
app.CheckDataButton.ButtonPushedFcn = createCallbackFcn(app, @CheckDataButtonPushed, true);
app.CheckDataButton.Position = [28 517 100 22];
app.CheckDataButton.Text = 'Check Data';
% Create UITable
app.UITable = uitable(app.UIFigure);
app.UITable.ColumnName = {'Type of element'; 'Length'; 'Radius 1'; 'Radius 2'; 'Rho'; 'G-Value'};
app.UITable.RowName = {};
app.UITable.DisplayDataChangedFcn = createCallbackFcn(app, @UITableDisplayDataChanged, true);
app.UITable.Position = [239 117 688 253];
% Create CalculatefeigButton
app.CalculatefeigButton = uibutton(app.UIFigure, 'push');
app.CalculatefeigButton.Position = [28 459 100 22];
app.CalculatefeigButton.Text = 'Calculate f eig';
% Create SimulationdesTorsionsverhaltenseinesRotorstrangsmitMATLABLabel
app.SimulationdesTorsionsverhaltenseinesRotorstrangsmitMATLABLabel = uilabel(app.UIFigure);
app.SimulationdesTorsionsverhaltenseinesRotorstrangsmitMATLABLabel.FontAngle = 'italic';
app.SimulationdesTorsionsverhaltenseinesRotorstrangsmitMATLABLabel.Position = [157 666 368 28];
app.SimulationdesTorsionsverhaltenseinesRotorstrangsmitMATLABLabel.Text = {'Simulation des Torsionsverhaltens eines Rotorstrangs mit MATLAB'; 'Simulation of the torsional behavior of a rotor strand with MATLAB '};
% Create SToRMLabel
app.SToRMLabel = uilabel(app.UIFigure);
app.SToRMLabel.FontSize = 32;
app.SToRMLabel.Position = [28 660 110 39];
app.SToRMLabel.Text = 'SToRM';
% Create Label
app.Label = uilabel(app.UIFigure);
app.Label.Position = [7 645 983 22];
app.Label.Text = '______________________________________________________________________________________________________________________________________________';
% 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 = SToRM_20211208
% 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

Answers (1)

Walter Roberson
Walter Roberson on 21 Dec 2021
DataImport = @function_DataImport; %Funktion zum Import der DataMatrix
That is a function handle.
dataMatrix = DataImport;
dataMatrix will be a copy of the function handle. You are not invoking the function, you are just copying the handle.
If you had named function_DataImport directly, as in
dataMatrix = function_DataImport;
then that would have been an invocation of the function with no parameters. But automatic invocation does not happen for function handles, only for direct function names.

Community Treasure Hunt

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

Start Hunting!