matlab - Finding instantaneous frequency -
i want find instantaneous frequency on window of signal. taking small part of signal , trying find instantaneous frequency in window. frequency not matching actual frequency of signal. below code.
close all; clear all; clc fs = 25000; t = 0.5; t = 0:1/fs:t; n = length(t); m = floor(n/4); f1 = 100; z1 = cos(2*pi*f1*t(1:m)); f1 = 200; z2 = cos(2*pi*f1*t(1:m)); f1 = 300; z3 = cos(2*pi*f1*t(1:m)); f1 = 400; z4 = cos(2*pi*f1*t(1:(n-3*m))); z = [z1 z2 z3 z4]; window = 100; wstart = 1; wend = wstart + window; freqs = []; while wend < length(z) x = z(wstart:wend); y = t(wstart:wend); h=hilbert(x); unrolled_phase = unwrap(angle(h)); dx = diff(unrolled_phase); dy = diff(y); p = dx./dy; inst_freq = p/(2*pi) + 2*pi; freqs = [freqs inst_freq]; wstart = wend; wend = wstart + window; end
the plot of 'freqs' this:
i think there wrong way calculating frequencies not sure. can please help? need frequencies 100,200,300 , 400 evident code. want find beginning point(time) of each frequency
the first, theoretical answer, signal combination of several frequencies. also, if decomposing signal ranges of 100 hz bins of 100hz, 200hz, 300hz, etc. not able recreate signal same signal transformed. is, inverse transform can use 4 freqs, , combine in way such input signal , recovered signal not sound same!
Comments
Post a Comment