How to Import Vectors in AppDesigner

6 views (last 30 days)
Francesco Carraro
Francesco Carraro on 27 Feb 2020
Commented: Adam on 27 Feb 2020
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 Comment
Adam
Adam on 27 Feb 2020
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

Sign in to comment.

Answers (1)

Emerson Nithiyaraj
Emerson Nithiyaraj on 27 Feb 2020
If loading the data file is the only problem, check whether the data file is present in your current working directory.
  1 Comment
Francesco Carraro
Francesco Carraro on 27 Feb 2020
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');

Sign in to comment.

Categories

Find more on Develop uifigure-Based Apps in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!