How can i found the infelction point from the data and remove the data before the first and last infelction points.
Mostrar comentarios más antiguos
I need to find the inflection point from the experimental data using matlab. Kindly help me for that. Thanks in advance
Respuestas (2)
The data are quite noisy. After filtering them, it is not obvious what sort of inflection point you want or how to define it.
M1 = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1265285/data.xlsx')
x = M1(:,1);
y = M1(:,2);
% yf = sgolayfilt(y, 3, 451);
Fs = 1/mean(diff(x))
Fn = Fs/2;
L = numel(x);
NFFT = 2^nextpow2(L);
FTy = fft((y-mean(y)).*hann(L),NFFT)/L;
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
figure
semilogy(Fv, abs(FTy(Iv))*2)
grid
xlim([0 10])
yf = lowpass(y, 0.5, Fs, 'ImpulseResponse','iir');
dyfdx = gradient(yf) ./ gradient(x);
d2yfdx2 = gradient(dyfdx) ./ gradient(x);
figure
yyaxis left
plot(x, y, 'DisplayName','Unfiltered Data')
hold on
plot(x, yf, '-r', 'DisplayName','Filtered Data')
hold off
ylabel('Data')
yyaxis right
plot(x, dyfdx, 'DisplayName','First Derivative Of Filtered Data')
hold on
plot(x, d2yfdx2, 'DisplayName','Second Derivative Of Filtered Data')
hold off
yline(0, '-g')
ylabel('Derivatives')
grid
legend('Location','best')
.
8 comentarios
JINU SUDHAKARAN Mr
el 20 de En. de 2023
JINU SUDHAKARAN Mr
el 20 de En. de 2023
Editada: JINU SUDHAKARAN Mr
el 20 de En. de 2023
Finding the second derivative zero-crossings is straightforward.
Try something like this —
M1 = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1265285/data.xlsx')
x = M1(:,1);
y = M1(:,2);
% yf = sgolayfilt(y, 3, 451);
Fs = 1/mean(diff(x))
Fn = Fs/2;
L = numel(x);
NFFT = 2^nextpow2(L);
FTy = fft((y-mean(y)).*hann(L),NFFT)/L;
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
Fco = 0.5;
figure
plot(Fv, mag2db(abs(FTy(Iv))*2), 'DisplayName','Fourier Transform')
grid
xlim([0 10])
xlabel('Frequency')
ylabel('Magnitude (dB)')
xline(Fco, '-r', 'DisplayName',sprintf('Lowpass Filter Cutoff Frequency: %.2f',Fco))
legend('Location','best')
yf = lowpass(y, Fco, Fs, 'ImpulseResponse','iir');
dyfdx = gradient(yf) ./ gradient(x);
d2yfdx2 = gradient(dyfdx) ./ gradient(x);
d2zix = find(diff(sign(d2yfdx2)));
for k = 1:numel(d2zix) % Second Derivative Zero-Crossings
idxrng = max(1,d2zix(k)-1) : min(d2zix(k)+1, numel(x));
xz(k,:) = interp1(d2yfdx2(idxrng), x(idxrng), 0);
yfz(k,:) = interp1(x, yf, xz(k));
end
Function_Value_At_Inflection_Points = table(xz, yfz, 'VariableNames',{'x','y'})
figure
yyaxis left
plot(x, y, 'DisplayName','Unfiltered Data')
hold on
plot(x, yf, '-r', 'DisplayName','Filtered Data')
hold off
ylabel('Data')
yyaxis right
plot(x, dyfdx, 'DisplayName','First Derivative Of Filtered Data')
hold on
plot(x, d2yfdx2, 'DisplayName','Second Derivative Of Filtered Data')
hold off
yline(0, '-g', 'DisplayName','Derivatives 0 Line')
for k = 1:numel(xz)
xline(xz(k), '--m', sprintf('x = %.2f',xz(k)), 'DisplayName', sprintf('Inflection Points x = %.2f',xz(k)))
end
ylabel('Derivatives')
grid
legend('Location','best')
This entirely depends on how you want to define the inflection points and how you want to process the signal before calculating them.
.
JINU SUDHAKARAN Mr
el 25 de En. de 2023
JINU SUDHAKARAN Mr
el 25 de En. de 2023
Editada: JINU SUDHAKARAN Mr
el 27 de En. de 2023
Star Strider
el 27 de En. de 2023
Here, I simply calculated and plotted the Fourier transform, and then used that to choose the passband for the lowpass filter. That choice is a bit empirical, so I experimented until I got a filtered result that I liked. (I initially used the sgolayfilt function, however that did not produce the result that I wanted, so I went with a frequency-selective filtering approach.)
That is all there is to it. As to how I arrived at the approach I used, it is simply the result of my experience in such things.
JINU SUDHAKARAN Mr
el 27 de En. de 2023
Star Strider
el 27 de En. de 2023
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
Steven Lord
el 16 de En. de 2023
0 votos
The ischange, islocalmin, and/or islocalmax functions may be of use to you, as might the corresponding Live Editor Tasks Find Change Points and Find Local Extrema.
Categorías
Más información sobre Functions en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



