Power fit with 3 parameters
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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; % X values
y1 = 2*(x.^2); % example data - power function 1
y2 = 2*(x.^2.1); % example data - power function 2
y3 = 2*(x.^2.2); % example data - power function 3
z1 = ones(size(y1)).*16; % treatment type
z2 = ones(size(y1)).*32; % treatment type
z3 = ones(size(y1)).*128; % treatment type
% plot the different groups
figure
plot(x,y1,x,y2,x,y3); hold on;
% fit a curve to the first data group to extract the original power function parameters
[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
0 commentaires
Réponses (1)
Abhisek Pradhan
le 9 Août 2019
As per the code from a given value of X, we get three values of Y, this can be done by using fit function for all three corresponding datasets of X and Y.
Again, using the fit Function with a suitable fitting algorithm we can form a relation between Y and Z. And for different Z values we can get corresponding Y values. Thus, we can predict Y values for given values of X and Z.
0 commentaires
Voir également
Catégories
En savoir plus sur Fit Postprocessing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!