App Designer input arguments

9 vues (au cours des 30 derniers jours)
Katarzyna Dragun
Katarzyna Dragun le 5 Août 2019
Hi,
I am using the App Designer for the first time (MatLab 2019a) and I am strugging with a basic problem - I am using a script where I create some variables and call the app. I want to use the variable from the workspace inside the app. I tried to use it as an app Input Argument but in many ways, it does not work. My code is below (the app). The error message I am getting is 'Cannot run with provided input arguments. Caused by: Not enough input arguments.' Can someone tell me what I am doing wrong?
classdef Experiment_app1 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
PLAYButton matlab.ui.control.Button
HvorhjtEditFieldLabel matlab.ui.control.Label
HvorhjtEditField matlab.ui.control.NumericEditField
Image matlab.ui.control.Image
Loudnessscalingexperimentnoise1Label matlab.ui.control.Label
NextButton matlab.ui.control.Button
end
properties (Access = private)
data
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app, noise1)
Experiment_app1.data = load('CI_loudness_experiment_2.mat', noise1)
end
% Button pushed function: PLAYButton
function PLAYButtonPushed(app, event)
sound(noise1(:,1),Fs)
end
  3 commentaires
Katarzyna Dragun
Katarzyna Dragun le 5 Août 2019
I changed it to app.data = load(...) as you suggested (this is what I already tried it before actually...).
In my main script I am just calling the name of the app:
Experiment_app1
uiwait(gcf);
Adam
Adam le 6 Août 2019
But the whole point of this was to have input arguments wasn't it? Yet you are calling it without passing in that input argument! Pass in whatever 'noise1' should be.

Connectez-vous pour commenter.

Réponses (1)

Harsha Priya Daggubati
Harsha Priya Daggubati le 8 Août 2019
Hi,
I assume that your mat file CI_loudness_eperiment_2contains a variable named noise1’. The approach you are following seems correct as per my knowledge. I suggest debug through the code with breakpoints and make sure whether the data loads as intended. If the problem persists, I ask to properly attach the error messages you are getting.

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by