필터 지우기
필터 지우기

Error (( Not enough arguments))

조회 수: 1 (최근 30일)
Melika Eft
Melika Eft 2023년 3월 11일
답변: Walter Roberson 2023년 3월 11일
Hello , I just wrote this code and it gives me that error at line ( N=length (x))thank you indeed
function y = myhilbert(x)
% Compute the Hilbert transform of x using the Fourier transform method.
% Source: https://en.wikipedia.org/wiki/Hilbert_transform#Discrete-time_Hilbert_transform
N = length(x);
X = fft(x);
if mod(N, 2) == 0 % even-length case
h = [1, 2*ones(1, N/2-1), ones(1, 2)];
else % odd-length case
h = [1, 2*ones(1, (N-1)/2)];
end
Y = h .* X;
y = ifft(Y);
end
  댓글 수: 2
dpb
dpb 2023년 3월 11일
I tried to format the code; not positive it's identical to your posted; the editor keeps inserting comments superficiously when try to break lines but it looks like a reasonable approximation anyway. Use the "Code" button to format your code going forward and make any fixes needed above.
You'll have to show us the code you tried to run, the message in isolation would not seem to apply to the above code.
You're also going to have a problem in the assimilation of the h vectors, you try to catenate a row vector column vectors of differing heights; you'll need to create a column vector instead; use the ";" operator instead of the "," inside the brackets.
Walter Roberson
Walter Roberson 2023년 3월 11일
ones(1, something) is a single row, so all of the entries in the [] are one row tall and different columns wide. Using , between the parts is fine for that.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2023년 3월 11일
You tried to run the code by pressing the green Run button. When you press the Run button, the function is run without any inputs.
The will never look inside the calling environment or the base workspace to try to find a value for a named parameter that was not passed in at run time.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by