Error (( Not enough arguments))

3 visualizaciones (últimos 30 días)
Melika Eft
Melika Eft el 11 de Mzo. de 2023
Respondida: Walter Roberson el 11 de Mzo. de 2023
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 comentarios
dpb
dpb el 11 de Mzo. de 2023
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 el 11 de Mzo. de 2023
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.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 11 de Mzo. de 2023
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.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by