selecting audiofile from app (appdesigner) and then run the file doesnt work

1 visualizzazione (ultimi 30 giorni)
Hello!,
I am trying to run an .m script that uses audioread.
And i want to select te audiofile in the app with an 'OPEN' button and then run the .m script with an 'START' button. .
but when i try to run the script from the app i get this message :
Undefined function or variable 'bestand'.
Error in SireneOpdrachtV22 (line 5)
lol = bestand;
Error in run (line 91)
evalin('caller', strcat(script, ';'));
Here is the code for the open button:
function OPENButtonPushed(app, event)
[file,path] = uigetfile( ...
{'*.wav;*.mp3',...
'AUDIO (*.wav,*.mp3)';
'*.*', 'All Files (*.*)'}, ...
'Select a File');
if isequal(file,0)
disp('User selected Cancel');
else
disp(['User selected ', fullfile(path,file)]);
end
assignin('base','bestand',fullfile(path,file))
end
Here is the code for the start button:
function STARTButtonValueChanged(app, event)
run SireneOpdrachtV22.m
end
end
Here is the code of the .m script:
[signaal,Fs] = audioread(bestand);
Can someone help me?
Greeting!

Risposte (1)

Walter Roberson
Walter Roberson il 11 Lug 2019
This is completely expected. run() does not execute within the context of the base workspace: run() executes within the context of the calling function. You assignin() to the base workspace, but you read out of the context of STARTButtonValueChanged()

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by