Receiving "too many output arguments" error in this code
62 ビュー (過去 30 日間)
古いコメントを表示
I am trying to make a effects panel on Matlab App Designer using switch-case logic in order to check which filters are toggled and which are not.
function applyActiveTransformations(app)
audio = app.origFXAudioData;
for i = 1:length(app.activeTransformations)
switch app.activeTransformations{i}
case 'highpass'
cutoffFreq = (app.FxFs/2) - 100;
normalizedCutoff = cutoffFreq/(app.FxFs/2);
[b,a]=butter(4, normalizedCutoff, ...
'high');
audio = filtfilt(b,a,audio);
case 'lowpass'
cutoffFreq = (app.FxFs/2) - 5;
[b,a] = butter(4, cutoffFreq / (app.FxFs/2), 'low');
audio = filtfilt(b,a,audio) ;
case 'bandpass'
lowCutoff=(app.FxFs/2) - 10;
highCutoff = (app.FxFs/2) - 500;
[b,a]= butter(4, [lowCutoff, highCutoff]/(app.FxFs/2),'bandpass');
audio = filtfilt(b,a,audio);
case 'chipmunk filter'
nsemitones = 9;
audio = shiftPitch(audio,nsemitones);
case 'normalize'
audio = audio/max(abs(audio(:)));
end
end
app.procFxAudioData = audio;
end
Here is the callback function for one of the filters. The others follow the same logic:
function highpassButtonPushed(app, event)
if app.highpassButtonPushed.Value == 1
app.activeTransformations{end+1} = 'highpass';
else
app.activeTransformations = setdiff(app.activeTransformations, {'highpass'},'stable');
end
app.applyActiveTransformations();
end
10 件のコメント
Walter Roberson
2024 年 12 月 7 日 23:00
Hmmm, change
HIGHBUTTONPUSHED = app.highpassButtonPushed;
whos HIGHBUTTONPUSHED
to
whos app event
for testing purposes.
At the moment, it appears that app is non-scalar and might possibly not be an app at all.
採用された回答
Walter Roberson
2024 年 12 月 8 日 0:00
編集済み: Walter Roberson
2024 年 12 月 8 日 0:01
You define
function highpassButtonPushed(app, event)
which declares highpassButtoPushed as a function that returns no outputs.
You call
disp(app.highpassButtonPushed.Value)
That asks to invoke the function highpassButtonPushed and return some value from that, and index that output at field Value . But highpassButtonPushed is a function that returns no outputs, so the results of it cannot be processed.
You might possibly be wanting to do
disp(app.highpassButton.Value)
2 件のコメント
Stephen23
2024 年 12 月 8 日 3:36
"I'm still receiving this error."
Because you still have the same bug here:
if app.highpassButtonPushed.Value == 1
which should be replaced with this:
if app.highpassButton.Value == 1
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Audio Processing Algorithm Design についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!