Filter löschen
Filter löschen

I am creating a hybrid filter of median and wiener but why does this error occurs ?

3 Ansichten (letzte 30 Tage)
Error using medfilt1
Expected input number 2, N, to be a scalar.
Error in medfilt1 (line 61)
validateattributes(n, {'numeric'}, ...
  1 Kommentar
Jan
Jan am 7 Feb. 2023
The error message seems to be clear. So please post the complete error message and the line of code, which causes the problem. What is the ontents of the 2nd input of medfilt1?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Manikanta Aditya
Manikanta Aditya am 20 Mär. 2023
Hi Dhinagaran,
As per my understanding, you are creating a hybrid median and wiener filter, but you are facing error with ‘medfilt1’ function. The second input to the ‘medfilt1’ function is expected to be a scalar value, but it appears to be something else. If you are passing an array or vector as the second input, that might be the cause of error.
The medfilt1 function is used to perform a 1-D median filter on a signal. It takes two inputs: the first input is the signal to be filtered, and the second input is the length of the filter window (i.e., the number of samples to use for each median calculation).
Here is an example of how to use the ‘medfilt1’ function:
% Create a signal to filter
t = 0:0.01:1;
x = sin(2*pi*5*t) + randn(size(t));
% Apply a median filter with a window length of 5 samples
y = medfilt1(x, 5);
% Plot the original signal and the filtered signal
plot(t, x, 'b', t, y, 'r');
legend('Original signal', 'Filtered signal');
For further reference, please check the link about medfilt1 function:
I hope this resolves the issue you are facing.

Community Treasure Hunt

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

Start Hunting!

Translated by