Receiving "too many output arguments" error in this code
이전 댓글 표시
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일
Which line is it complaining about, thinking that it has too many outputs ?
Stephen23
2024년 12월 7일
Please show us the complete error message. That means all of the red text.
Rik
2024년 12월 7일
That is not the complete message.
Walter Roberson
2024년 12월 7일
The implication is that somehow app.highpassButtonPushed has become non-scalar, so app.highpassButtonPushed.Value is structure expansion (or object expansion) resulting in multiple parameters passed to disp()
However: the highpassButtonPushed code that you posted does not contain any disp() in it, so either you did not post the correct code or else the wrong version of the code is (somehow) executing.
Ria
2024년 12월 7일
편집: Walter Roberson
2024년 12월 7일
Walter Roberson
2024년 12월 7일
For the purposes of testing, on the line before
disp(app.highpassButtonPushed.Value)
insert
HIGHBUTTONPUSHED = app.highpassButtonPushed;
whos HIGHBUTTONPUSHED
and tell us what the result is at the time of the error.
Ria
2024년 12월 7일
Walter Roberson
2024년 12월 7일
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
2024년 12월 7일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!