Not Enough Input Arguments
Afficher commentaires plus anciens
Hi, I'm very new to MATLAB and I am having some trouble. Could somebody please explain what this error is and how to fix it?
Its written
"convolution requires more input arguments to run:
convolution(x,h)
enter input arguments by typing them now, then press Enter to run. The values you enter will be set as the default inputs when you click the Run button in the future."
let say i want to input x = [1 2 3 4]; h = [1 -1 1 -1];
where should i put it?
function [ Y ] = convolution( x,h )
m=length(x);
n=length(h);
X=[x,zeros(1,n)];
H=[h,zeros(1,m)];
for i=1:n+m-1
Y(i)=0;
for j=1:m
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
end
end
end
% using inbuilt command
yin = conv(x,h);
xaxis = 0:1:n+m-2;
subplot(2,1,1)
stem(xaxis,Y); xlabel('n value'); ylabel('y value'); title('Manual Convolution');
grid on;
subplot(2,1,2)
stem(xaxis,yin); xlabel('n value'); ylabel('y value'); title('Convolution using conv');
grid on;
end
2 commentaires
Jonas
le 18 Avr 2021
i have no problems running this code, it just works. i'm running 2021b
i'm just typing
x = [1 2 3 4]; h = [1 -1 1 -1];
convolution(x,h)
in the command line.
It just looks like you try to run a function by clicking the Run button and then entering the values and something went wrong there.
Cris LaPierre
le 18 Avr 2021
*2021a
Réponses (1)
Jan
le 18 Avr 2021
"when you click the Run button in the future" - This means, that you tried to run the programn pressing the green triangle, the "Run button". Doing this does not define the inputs of a function. It is like instructing Matlab to run: sin() without providing inputs.
Type this in the command window:
x = [1 2 3 4];
h = [1 -1 1 -1];
Y = convolution( x,h )
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!