[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How do YOU handle this disparity in fft?
From: |
Macy |
Subject: |
Re: How do YOU handle this disparity in fft? |
Date: |
Wed, 12 Feb 2014 05:19:56 -0800 |
By the way, be very careful naming variables mnemonically. I just labeled the
'sig with noise' as 'sign'. Well, you can see the problem when I went to do
something else.
The program below allows you to preserve the energy in an 'actual' voltage
waveform. Both, a 1 Vrms signal is returned as 1 and a DC signal of 1 Vdc is
returned as 1.
You can easily add noise density function by putting in the value,
vn=Vrms/rtHz, as
noisesignal = vn*randn(1,vectorlength)*sqrt(samplingratepersec/2);
where vn is the noise density function in v/rtHz, and
vectorlength matches the signal length you add it to, and
samplingratepersec is the sampling rate
fftreal.m
function [out,ford]=fftreal(in);
% calculates the 'adjusted' values of the fft, only half the fft is returned
% use the form [b,ford]=fftreal(sig);
% the ordinate, ford, is returned to enable plotting, remember to adjust it.
% input a realtime waveform a vector only
% out is the adjusted values of the fft in true energy values
% ford is the ordinate of the fft, to accurately plot ford is to be
multiplied by
% the Sampling rate divided by the packet length.
if (nargin ~=1)
help fftreal;
return;
endif
[rowsin,columnsin]=size(in);
if( rowsin ~=1)
disp("for now, only accept a vector");
return;
endif
if ( 2*round(columnsin/2+.1) ~= columnsin)
disp("for now, only accept an EVEN vector");
return;
endif
n=round(columnsin/2);
b=sqrt(2)*fft(in)/columnsin;
out=[b(1)/sqrt(2),b(2:n)];
ford=([1:n]-1)/n;
endfunction;
and, please, NO snickering at how simple this program is, it took a LONG time
to get here.
- How do YOU handle this disparity in fft?, Macy, 2014/02/10
- Re: How do YOU handle this disparity in fft?, Macy, 2014/02/11
- Re: How do YOU handle this disparity in fft?,
Macy <=
- Re: How do YOU handle this disparity in fft?, Macy, 2014/02/13
- Re: How do YOU handle this disparity in fft?, Macy, 2014/02/14
- Re: How do YOU handle this disparity in fft?, Macy, 2014/02/15
- Re: How do YOU handle this disparity in fft?, Macy, 2014/02/16
- Re: How do YOU handle this disparity in fft?, Macy, 2014/02/16