Effacer les filtres
Effacer les filtres

Error (( Not enough arguments))

1 vue (au cours des 30 derniers jours)
Melika Eft
Melika Eft le 11 Mar 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 commentaires
dpb
dpb le 11 Mar 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 le 11 Mar 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.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 11 Mar 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.

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by