Plot Problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Plot Problem

Thomas D. Dean-2
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

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Plot Problem

Andreas Weber-6
Am 06.08.2017 um 21:09 schrieb Thomas D. Dean:
> plot([m1;m2]);  ## seems to hang forever
> What am I doing wrong?

size of m1 and m2 are both 1x7501

plot([m1;m2]);
would plot 7501 lines! I guess waht you want is
plot([m1,m2]);

-- Andy

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Plot Problem

Andreas Weber-6
Am 06.08.2017 um 21:24 schrieb Andreas Weber:
> Am 06.08.2017 um 21:09 schrieb Thomas D. Dean:
>> plot([m1;m2]);  ## seems to hang forever
> I guess what you want is
> plot([m1,m2]);

Ah, no. what you want is plot([m1;m2]'), right?

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Plot Problem

Thomas D. Dean-2
In reply to this post by Andreas Weber-6
On 08/06/2017 12:24 PM, Andreas Weber wrote:

> Am 06.08.2017 um 21:09 schrieb Thomas D. Dean:
>> plot([m1;m2]);  ## seems to hang forever
>> What am I doing wrong?
>
> size of m1 and m2 are both 1x7501
>
> plot([m1;m2]);
> would plot 7501 lines! I guess waht you want is
> plot([m1,m2]);
>
> -- Andy
>

Correct.

What the OP wanted was plot(t,[m1;m2]);

Thanks.
Tom Dean

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Loading...