MATLAB Answers

0

App Designer input arguments

Katarzyna Dragun さんによって質問されました 2019 年 8 月 5 日
最新アクティビティ Harsha Priya Daggubati さんによって 回答されました 2019 年 8 月 8 日
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 件のコメント

Adam
2019 年 8 月 5 日
How are you calling the app?
Also
% Code that executes after component creation
function startupFcn(app, noise1)
Experiment_app1.data = load('CI_loudness_experiment_2.mat', noise1)
end
will create a struct, assign your loaded data to a field of that struct, then throw it away. I assume you want to call
app.data = load( ... )
instead, to actually load it into the app.
Katarzyna Dragun 2019 年 8 月 5 日
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
2019 年 8 月 6 日
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.

サインイン to comment.

1 件の回答

回答者: Harsha Priya Daggubati 2019 年 8 月 8 日

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.

  0 件のコメント

サインイン to comment.



Translated by