How to Import Vectors in AppDesigner

2 次查看(过去 30 天)
Hello everyone,
I need to import a Matlab data File in a script made with Appdesigner, and plot the vectors, but I can't load properly the file.
I have to use the vectors that are storage in "('E:\UniPd\Motostudent\Dati\Prova_export_MATLAB.mat')" as variables 1/2. I've already tried to use 'load' function but Matlab gives me error. Here it is a part of the script:
classdef App_Telemetry_1 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
UIAxes matlab.ui.control.UIAxes
UIAxes2 matlab.ui.control.UIAxes
Slider matlab.ui.control.Slider
UIAxes3 matlab.ui.control.UIAxes
ThrottleTextAreaLabel matlab.ui.control.Label
ThrottleTextArea matlab.ui.control.TextArea
BrakeTextAreaLabel matlab.ui.control.Label
BrakeTextArea matlab.ui.control.TextArea
LeanAngleTextAreaLabel matlab.ui.control.Label
LeanAngleTextArea matlab.ui.control.TextArea
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 = [0 0 1280 720];
app.UIFigure.Name = 'UI Figure';
% Create Telemetry Data Portion Plot
app.UIAxes = uiaxes(app.UIFigure);
title(app.UIAxes, 'Data Portion')
xlabel(app.UIAxes, '')
ylabel(app.UIAxes, '')
app.UIAxes.Position = [1 298 751 421];
%time= variable 1
%y1 = variable 2
plot(app.UIAxes,time,y1,'r');
  1 个评论
Adam
Adam 2020-2-27
Use the form of load which returns a structure as output (which is recommended in any case) rather than just dumping the variables into the workspace as a regular call to load will do.
doc load

请先登录,再进行评论。

回答(1 个)

Emerson Nithiyaraj
Emerson Nithiyaraj 2020-2-27
If loading the data file is the only problem, check whether the data file is present in your current working directory.
  1 个评论
Francesco Carraro
Francesco Carraro 2020-2-27
Yes I've already checked and the file is there; this is the error that Matlab shows
>> App_Telemetry_1
Error using load
Attempt to add "L003_time" to a static workspace.
See Variables in Nested and Anonymous Functions.
Error in App_Telemetry_1/createComponents (line 40)
load('E:\UniPd\Motostudent\Dati\Prova_export_MATLAB.mat');

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by