I have the following custom function that must be fitted to the data:
function y=reflectometriaRC(x,v0,t0,v1,t1,v2,v3,tau)
y=zeros(size(x));
for i=1:length(x)
if x(i)<t0,
y(i)=v0;
elseif x(i)<t0+t1,
y(i)=v1;
else
y(i)=v2+v3*(1-exp(-(x(i)-(t0+t1))/tau));
end
end
end
You can see an example of this function in the following image:
The problem is that i cannot find the correct options to make the "fit" function to work propertly.
I have tried things like this:
x=transpose([0:200*10^-12:1200*10^-9]);
y=reflectometriaRC(x,0,100*10^-9,0.98,100*10^-9,0,1.96,250*10^-9);
ft = fittype('reflectometriaRC(x,v0,t0,v1,t1,v2,v3,tau)');
f = fit( x, y, ft,'Robust','on', 'MaxFunEvals',600000,'MaxIter',400000000, 'StartPoint', [0, 0, 0.5, 0, 0,0, 0], 'Lower',[0, 0, 0.5, 0, 0,0, 0] );
coeffvalues(f)
But the result is just some sort of step function.
Any idea what would be a good configuration to make the fitting work?
The idea of this code is to get a measure from an oscilloscope used with a pulse generator like a basic TDR. The device under test in an RC circuit at the end of a 1m coaxial line. The image in the link above is in the scale of the possible values in seconds and volt.