Points of Inflection for Sine Curve
22 ビュー (過去 30 日間)
古いコメントを表示
In the code below, I have successfully detected the peaks of the sine curve. I have also put the peaks on the plot. May someone PLEASE help me now identify the points of inflection. It is where the graphs goes from concave up to concave down (NOT the peaks). The points of inflection should be points across the Sine curve that go across the middle of the graph. The code is below. If you could also mark the points on the graph that would be much appreciated. Thanks!
I found a solution to this problem, it stated that
***************************************************************************** "If your curve are data (not calculated by a function) I would use the gradient function to calculate the derivative. To find the zero-crossing of the derivative, you can either use a threshold test, or if appropriate for your derivative, the interp1 function." *************************************************************************
I just dont know how to code the above..but here is my code again below. Thanks again guys: Basically,inflection points in the signal is to be determined automatically by detecting zero-crossings in derivatives of the signal. I need help finding the zero-crossings of the signal. Thank you!!
x = 1:500;
X = x;
J = 1;
Fs = 499;
N = J*Fs;
t = 0: 1/Fs : J;
Fn = 3; % this control the number of cycles/periods
deltaJ = 0.0020;
deltax = 1;
y_sine_25HZ = sin(Fn*2*pi*t);
y = y_sine_25HZ ;
plot(x,y, 'k.')
% drvY = diff(y)/deltax; % one unit shorter than y
% drvY = [drvY , drvY(end)]; % making up for the missing point
% secondDrvY = diff(drvY)/deltax;
% secondDrvY = [secondDrvY, secondDrvY(end)];
% [~,locup]=findpeaks(y) % (+)ive peaks % location up
% [~,locdn]=findpeaks(-y) % (-)ive peaks (positive negative y) % location down
dy=[0 sign(diff(y))];
locdn = find((diff(dy))==2) % location down
locup = find((diff(dy))==-2) % location up
plot(t,y)
ylim([-1.05 1.05])
hold on
scatter(t(locup)',y(locup)',30,'r','*')
scatter(t(locdn)',y(locdn)',30,'g','d','filled')
3 件のコメント
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!