MATLAB Answers

Defining my objective function using vector of variables for lsqnonlin

3 views (last 30 days)
Abdelwahab Afifi
Abdelwahab Afifi on 12 May 2020
Edited: Abdelwahab Afifi on 12 May 2020
I wanna use lsqnonlin for estimating vector of variables of length 6
function F = myfun()
global X % regression matrix of (nx6)
global Y % output vector (nx1)
F = Y - ( w(1)*X(:,1) + w(2)*X(:,2) + w(3)*X(:,3) + w(4)*X(:,4) + w(5)*X(:,5) + w(6)*X(:,6) );
end
How can I dynamically define my function to adapt with any change in the number of variables (m) when the regression matrix dimesions (nxm) is changed. as follow
F = Y - ( w(1)*X(:,1) + w(2)*X(:,2) + w(3)*X(:,3) + .. + w(m)*X(:,m) );

  0 Comments

Sign in to comment.

Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!