Not Enough Input Arguments
显示 更早的评论
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 个评论
Jonas
2021-4-18
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
2021-4-18
*2021a
回答(1 个)
Jan
2021-4-18
"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 )
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!