Hi all,
I have 3 groups of XY data, these data are each pretty well described by a power function. Each group reflects a different treatment type (like drug dosage) and I would like this treatment type to be taken into account in the power function.
The aim would be to get one equation that can be used to predict Y given X and treatment type.
So far I have used the curve fitting toolbox to fit power functions to the curves quite easily like the example below, but I don't know what to do next.
Adding treatment type as a Z value doesn't really give a clear result, it seems that Matlab tries to fit a surface to the data which doesn't work very well - either because the data are too sparse or because the treatment type parameter is scaled differently to the others.
x = 1:100;
y1 = 2*(x.^2);
y2 = 2*(x.^2.1);
y3 = 2*(x.^2.2);
z1 = ones(size(y1)).*16;
z2 = ones(size(y1)).*32;
z3 = ones(size(y1)).*128;
figure
plot(x,y1,x,y2,x,y3); hold on;
[xData,yData] = prepareCurveData(x,y1);
ft = fittype('power1');
opts = fitoptions('Method','NonlinearLeastSquares');
opts.Display = 'Off';
opts.StartPoint = [2 2];
[fitresult, gof] = fit( xData, yData, ft, opts );
fitresult.a
fitresult.b