Error showing up then using (:)'

I am a begginer at Matlab. I'm making a feedforward comb filter. It says there is an error on this line:
inputSignal = inputSignal(:)';
inputSignal is supposed to be an audio file. This should be alright syntax wise, so I don't know where exactly is the problem. I also tried using just (:) and ', but it still says there is an error. If anyone could help me, it would mean a lot.
Here is the whole code:
% Shroeder-ov reverberator
% Feedforward comb filtar
function outputSignal = FFCF (inputSignal, delayLength, feedbackGain)
inputSignal = inputSignal(:)';
delayLine = zeros(1, delayLength);
outputSignal = zeros(size(inputSignal));
for n = 1:length(inputSignal)
combOutput = delayLine(end);
delayLine = circshift(delayLine, [0, 1]);
delayLine(1) = inputSignal(n) + feedbackGain * combOutput;
outputSignal(n) = combOutput;
end
outputSignal = outputSignal / max(abs(outputSignal));
end
% All pass filtar
function outputSignal = APF (inputSignal, delayLength, feedbackGain)
inputSignal = inputSignal(:)';
delayLine = zeros(1, delayLength);
outputSignal = zeros(size(inputSignal));
for n = 1:length(inputSignal)
allPassOutput = inputSignal(n) - feedbackGain * delayLine(end);
delayLine = circshift(delayLine, [0, 1]);
delayLine(1) = allPassOutput;
outputSignal(n) = allPassOutput;
end
end
function main
% Citamo audio fajl
audioFileRead = "sample.wav";
[input, Fs] = audioread(audioFileRead);
% Redna veza all pass filtra
allPass1 = APF (input, 1051, 0.7);
allPass2 = APF (allPass1, 337, 0.7);
allPass3 = APF (allPass2, 113, 0.7);
% 4 feed forward comb filtra
feedForward1 = FFCF (allPass3, 4799, 0.742);
feedForward2 = FFCF (allPass3, 4999, 0.733);
feedForward3 = FFCF (allPass3, 5399, 0.714);
feedForward4 = FFCF (allPass3, 5801, 0.697);
% Suma filtara
output = feedForward1 + feedForward2 + feedForward3 + feedForward4;
sound(output)
end

7 commentaires

Walter Roberson
Walter Roberson le 16 Sep 2023
When you pressed the green Run button to execute the code, what was your expectation about where it would search to find values for inputSignal?
Nikola
Nikola le 16 Sep 2023
I am not sure what do you mean by that. The values are given to it in the function main when I use the function.
Stephen23
Stephen23 le 16 Sep 2023
Modifié(e) : Stephen23 le 16 Sep 2023
@Nikola: please show us:
  • the line of code where you call that function,
  • the sizes and types of the inputs that you use when calling it,
  • the complete error message. This means all of the red text.
Nikola
Nikola le 16 Sep 2023
Modifié(e) : Walter Roberson le 16 Sep 2023
Here are the lines in which the function is called, and it's inputs:
feedForward1 = FFCF (allPass3, 4799, 0.742);
feedForward2 = FFCF (allPass3, 4999, 0.733);
feedForward3 = FFCF (allPass3, 5399, 0.714);
feedForward4 = FFCF (allPass3, 5801, 0.697);
allPass3 is the result of the function APF:
allPass3 = APF (allPass2, 113, 0.7);
The complete error message:
Not enough input arguments.
Error in shroederov_reverberator (line 6)
inputSignal = inputSignal(:)';
Here is the complete APF function if you need it as well:
function outputSignal = APF (inputSignal, delayLength, feedbackGain)
inputSignal = inputSignal(:)';
delayLine = zeros(1, delayLength);
outputSignal = zeros(size(inputSignal));
for n = 1:length(inputSignal)
allPassOutput = inputSignal(n) - feedbackGain * delayLine(end);
delayLine = circshift(delayLine, [0, 1]);
delayLine(1) = allPassOutput;
outputSignal(n) = allPassOutput;
end
end
DGM
DGM le 16 Sep 2023
Modifié(e) : DGM le 16 Sep 2023
When Stephen asks about "that function", he means where is main() being called? The answer is that it's not.
The error is on line 6. Walter seems to correctly intuited that this file is being executed as a script by hitting the play button. The contents of the first function in the file are executed without any of its input arguments being defined. This immediately results in an error.
In order to make a function do something, you need to call it with the appropriate arguments. The given block of code contains no lines which are not functions, so nothing normally would happen, because nothing calls any of the functions.
If you want to treat the file as a script with functions, call main() somewhere before the first function declaration. Alternatively, move the contents of main() so that they are outside of a function and so that they precede the first function declaration in the script.
Nikola
Nikola le 16 Sep 2023
It worked! I understand what I did wrong. Thank you so much! I moved the contents of main before the function declaration, and it works, I just need to get the values right, and the project should be finished.
DGM
DGM le 16 Sep 2023
Excellent. Glad to hear it.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Get Started with Signal Processing Toolbox dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by