Instantaneous frequency not plotting correctly in Matlab

Posted by user2951069 on Stack Overflow See other posts from Stack Overflow or by user2951069
Published on 2013-11-06T03:51:45Z Indexed on 2013/11/06 3:53 UTC
Read the original article Hit count: 198

Filed under:
|
|

I'm trying to convert square wave data to instantaneous frequency and plot against time. It works correctly for one data set, but three others are plotting as shown in the image: http://i.imgur.com/iuL648o.png

Time is linear, so it shouldn't be plotting like that. Anyone have any ideas as to what's going on? I'm using the following code:

ddiff = diff(flow(:,1));
locations = find(ddiff(1:end-1,1)>0.1 & ddiff(2:end,1) <=0.1);
for z = 2:length(locations)
    inst_freq(z-1) = 1/(time(locations(z))-time(locations(z-1)));
    freq_time(z-1) = time(locations(z));
end
plot(freq_time,inst_freq)

© Stack Overflow or respective owner

Related posts about matlab

Related posts about plot