Not Enough Input Arguments
조회 수: 3 (최근 30일)
이전 댓글 표시
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.
답변 (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 )
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!