help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Plot Problem


From: Thomas D. Dean
Subject: Plot Problem
Date: Sun, 6 Aug 2017 12:09:00 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

I have a problem where plot seems to run forever. At least for three minutes.

octave 4.3.0+.  Signal 1.3.2

A web example:
https://p5r.uk/blog/2009/filters-with-gnu-octave.html

% The sampling frequency in Hz.
Fsam = 1500;

% Nyquist frequency, in Hz.
% The Nyquist frequency is half your sampling frequency.
Fnyq = Fsam/2;

% The cut-off frequency of your Low pass filter in Hz.
% This frequency must be greater than 0 and less than Fnyq.
Fc=1/4;

% Create a first-order Butterworth low pass.
% The returned vectors are of legth n.
% Thus a first order filter is created with n = 2.
[b,a]=butter(2, Fc/Fnyq);


% Create a 5 seconds signal with 3 components:
% a 1 Hz and a 200 Hz sinusoidal component and some gaussian noise.
t=0:1/Fsam:5;
x=sin(2*pi*t) + sin(2*pi*200*t) + randn(size(t));

% Apply the filter to the input signal and plot input and output.
y=filter(b,a,x);
plot(t, [x; y])

m1 = abs(fft(x));
m2 = abs(fft(y))

subplot(2,1,1); plot(m1);  ## OK
subplot(2,1,2); plot(m2);  ## OK

close


plot([m1;m2]);  ## seems to hang forever

What am I doing wrong?

Tom Dean



reply via email to

[Prev in Thread] Current Thread [Next in Thread]