Too many input arguments error

조회 수: 1 (최근 30일)
Ben Masters
Ben Masters 2018년 10월 13일
댓글: Walter Roberson 2018년 10월 13일
So I'm making a script that takes in an audio file then allows the user to compress, echo, or graph the frequency. It is an unfinished script but I am attempting to get the compression function to work and every time I attempt to use compression it gives me the error "too many input arguments" Anyone have any idea what I'm doing wrong? My value of y is a really large column vector, Fs is the frequency which is 44100, and the compression ratio is user inputted. Also attachted the audio file I've been using if you want to give it a go.
choice = 1;
infile = inputdlg('Input name of .wav file');
soundVec = string(infile);
[y,Fs] = audioread(soundVec);
while choice ~= 5
switch choice
case 1
sound(y,Fs)
case 2
soundEcho(y, Fs, delay, echoGain)
case 3
compression = input('Input compression ratio: ');
compressionRatio(y,Fs,compression)
case 4
fftBar(soundVec, Fs)
case 5
closeall
% will close the window once exit is selected
end
choice=menu('Lab 5', 'Play Audio','Echo Effect','Compress','Frequency Spectrum', 'Exit');
end
The function is
function [compress] = compressionRatio(y,f,comp)
n = comp;
y(1:n:end);
sound(y,f);
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2018년 10월 13일
You do not show a complete traceback of the error, so we do not know which line is involved.
The function you posted defines an output variable but does not assign to it. That happens to work out because your code does not ask for the result of the function.
Your line
y(1:n:end);
extracts some values from y, but then discards them because you do not assign the result to a variable and the semicolon tells MATLAB not to display the value either.
You then play the same sound as was input.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by