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 Center および File ExchangeAudio and Video Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by