Not Enough Input Arguments

6 ビュー (過去 30 日間)
Andrea Simpson
Andrea Simpson 2021 年 4 月 12 日
コメント済み: Cris LaPierre 2021 年 4 月 18 日
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
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
Cris LaPierre 2021 年 4 月 18 日
*2021a

サインインしてコメントする。

回答 (1 件)

Jan
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 )

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by