Constrain axis when fitting curve in polyfit?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I am new to matlab and fitting a polynomial to a dataset using polyfit. I have managed to fit the data and forcing it to go through (0,0) using polyfitzero code. However, I want the polyfit curve to always stay positive (i.e. y>=0 at all times).
Is there a way to constrain the y axis to stay above 0?
My code:
function[Rsq]=Rfig(CT, log)
scatter(CT,log); %scatter plot of raw data
[p,S,mu] = polyfitZero(CT, log, 3);
f = polyval(p,CT,[],mu);
hold on
plot(CT,f)
Rsq=1 - (S.normr/norm(log - mean(log)))^2 %calculate Rsquared
end

Many thanks
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Interpolation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!