Good day I am new to Matlab. I have a function I want to optimise using lsqcurvefit the function is ETo=rf(0.45t+8)(H-R^m)/100 my xdata1=rf xdata2=t xdata3=R How can I go about it?

 Accepted Answer

I would do something like this:
% % % ETo=rf(0.45t+8)(H-R^m)/100 % Original Equation
% % % MAPPING: H = b(1), m = b(2) % Assuming These Are The Parameters To Be Estimated
xdata = [rf(:) t(:) R(:)]; % Force Column Vectors For Independnet Variables & Concatenate Into MAtrix
ETodata = ETo(:); % Force Dependent Variable To Be Column Vector (Assuming It Is Called ‘ETo’
ETo_fcn = @(b,xdata) xdata(:,1).*(0.45*xdata(:,2)+8).*(b(1)-xdata(:,3).^b(2))/100;
B0 = [H_est; m_est]; % Initial Parameter Estimates
B = lsqcurvefit(ETo_fcn, B0, xdata, ETodata)
Since I cannot test it, I am posting it as UNTESTED CODE. It should work, although it may require minor modification.

2 Comments

Ibrahim Laburta
Ibrahim Laburta on 16 Mar 2021
Edited: Ibrahim Laburta on 16 Mar 2021
Thanks man it works. I will comeback if I have any problems as I am a novice in Matlab. Thumps up to the support group.
As always, my pleasure!

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!