Receiving "too many output arguments" error in this code

조회 수: 62 (최근 30일)
Ria
Ria 2024년 12월 7일 0:13
댓글: Stephen23 2024년 12월 8일 3:36
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
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.
Ria
Ria 2024년 12월 7일 23:48
here is the new error:
To get started, type doc.
For product information, visit www.mathworks.com.
Name Size Bytes Class Attributes
app 1x1 8 riasupdates
event 1x1 8 matlab.ui.eventdata.ButtonPushedData
Error using riasupdates/highpassButtonPushed
Too many output arguments.
Error in riasupdates/highpassButtonPushed (line 1743)
disp(app.highpassButtonPushed.Value)
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, ...
Error while evaluating Button PrivateButtonPushedFcn.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
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
Ria
Ria 2024년 12월 8일 0:09
When I delete
disp(app.highpassButtonPushed.Value)
I'm still receiving this error.
Error using riasupdates/highpassButtonPushed
Too many output arguments.
Error in riasupdates/highpassButtonPushed (line 1743)
if app.highpassButtonPushed.Value == 1
Error in matlab.apps.AppBase>@(source,event)executeCallback(ams,app,callback,requiresEventData,event) (line 62)
newCallback = @(source, event)executeCallback(ams, ...
Error while evaluating Button PrivateButtonPushedFcn.
Stephen23
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 CenterFile Exchange에서 Audio Processing Algorithm Design에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by