MATLAB Answers

Error in fminsearch (line 200) fv(:,1) = funfcn(x,varargin{:});

조회 수: 41(최근 30일)
Muna Akhmedova
Muna Akhmedova 10 Jan 2021
편집: Matt J 10 Jan 2021
Hello,
I am new to MATLAB and I am trying to minimize a function using fminsearch (line 145, caviaropt.m). But when I do that an error pops "Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 3-by-1" . The function gives a 3x1 vector at initial points but the function has to return a scalar in order to apply fminsearch. How can I solve this issue?
Any help is much appreciated!

  댓글 수: 2

Matt J
Matt J 10 Jan 2021
Why does your function give a 3x1 vector? If you are trying to minimize a value fval, then your function should return fval.
Muna Akhmedova
Muna Akhmedova 10 Jan 2021
Oh i forgot to attach the data. That's because the data contain log returns of 3 companies (2517x3) and 3x1 vector is the RQ value for each company.

댓글을 달려면 로그인하십시오.

답변(1개)

Matt J
Matt J 10 Jan 2021
편집: Matt J 10 Jan 2021
Change the output of your function to a squared error over all 3 companies, or some other scalarization of the current output that you might be interested in minimizing.

  댓글 수: 0

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by