MATLAB: How to plot an inflection point from a temperature profile data source

inflection pointMATLAB and Simulink Student Suite

Hello everyone,
I have been trying to plot a tangent to a curve. My data source is a temperature profile from a TCL (temperature control lab). It has two heaters and the data from the arduino Leonardo is collected every second. I have a set of 2000 data points from the curve. While plotting the inflection point, I am not able to get the tangent to the curve. I tried to smooth the curve but no proper tangent could be found. I have the file attached. Can anyone please help me?

% sliding avg methodtemp_out = myslidingavg(temp, 50);figure(1),semilogx(time,temp,'b',time,temp_out,'r','linewidth',2);% first derivativedx = mean(diff(time));dy = [0; diff(temp_out)./dx];dy_out = myslidingavg(dy, 25);figure(2),plot(time,dy,'b',time,dy_out,'r','linewidth',2);% point of inflection = fin peak of first derivative (but not the first% sample transient)ind = find(time>time(1)+5 & time<time(1)+200);[peak,loc] = max(dy_out(ind));time_inflection = time(ind(loc));y_inflection = temp_out(ind(loc));dy_inflection = dy_out(ind(loc));% tangent equationtemp_tang = y_inflection+dy_inflection*(time-time_inflection);figure(3),plot(time,temp,'b',time,temp_out,'r',time(ind),temp_tang(ind),'--k','linewidth',2);legend('raw temp','smoothed','tangent at inlection point');