Too many input arguments error
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Walter Roberson
am 13 Okt. 2018
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.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Audio and Video Data finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!