Instantaneous frequency not plotting correctly in Matlab
- by user2951069
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)