Power fit with 3 parameters

조회 수: 4 (최근 30일)
Neuropragmatist
Neuropragmatist 2019년 7월 29일
답변: Abhisek Pradhan 2019년 8월 9일
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

답변 (1개)

Abhisek Pradhan
Abhisek Pradhan 2019년 8월 9일
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.
Following link has question related to concerned topic.

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by