Fitting data with custom equation and custom interval
Show older comments
I am trying to fit my data using the following code, but I couldnt find what is the problem in my code.
fy = @(a,b,x) 0.001*((a-x)/(a(1-x))).^(-b*a/(1-a));
x = [0,0.1, 0.2, 0.3, 0.4, 0.46, 0.55, 0.6];
y = [0.001, 0.00111499, 0.0011926, 0.0013699, 0.00161633, 0.00192075, 0.00274991, 0.00357156];
B = fmincon(@(c) norm(y - fy(c(1),c(2),x)), [1; 1], [],[],[],[], [0 0],[1 90]);
fprintf('PhiMax = %.15f\nVisco = %.15f\n', B)
xv = linspace(min(x), max(x));
figure(1)
plot(x, y, 'pg')
hold on
plot(xv, fy(B(1),B(2),xv), '-r')
hold off
grid
I also tried with this function :
fitfun = fittype( @(a,b,x) 0.001*((a-x)/(a(1-x))).^(-b*a/(1-a)));
my last question is it possible to add a custom interval for the variable for this fitfun function
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!