selecting audiofile from app (appdesigner) and then run the file doesnt work
1 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(1 个)
Walter Roberson
2019-7-11
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()
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!