Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-712.
31 views (last 30 days)
Show older comments
Massimiliano Vecoli
on 15 Nov 2019
Commented: Raunak Gupta
on 20 Nov 2019
Hi everyone,
I am trying to fit some data using "fminsearch" but i get the following problem "Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-712."
Here are the four lines.
var = aSlipFA(cornPOS(1,1):cornPOS(1,2));
ErrorMagicFormula =@(c) c(3)*sin(c(2)*atan(c(1)*var - c(4)*(c(1)*var - atan(c(1)*var)))) - FLatFA(cornPOS(1,1):cornPOS(1,2));
c0 = [2000,1.4,max(MyFLatFA(cornPOS(1,1):cornPOS(1,2))),0.9];
fit1 = fminsearch(ErrorMagicFormula,c0);
Thank you very much!
0 Comments
Accepted Answer
Raunak Gupta
on 19 Nov 2019
Hi,
In my understanding you are trying to optimize the ‘ErrorMagicFormula’ using fminsearch. The “Unable to Perform assignment” error message is due to the vector that is returned from the ‘ErrorMagicFormula’ calculation. The input to fminsearch should be a function that return scalar, so it is recommended to change the ‘ErrorMagicFormula’ such that it returns a scalar by using some transformation.
Here the variables var and FLatFA(cornPOS(1,1):cornPOS(1,2)) is supposedly a 1-by-712 vector.
5 Comments
Walter Roberson
on 20 Nov 2019
Small ammendment: if you multiply a 1 x 712 and a 712 x 1 and expect a 1 x 1 result, that is not vector multiplication, that is matrix multiplication. vector multiplication would be the .* operator and would give you a 712 x 712 result.
More Answers (0)
See Also
Categories
Find more on Get Started with Optimization 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!