solving equations with vector as the unknown variable
3 views (last 30 days)
Show older comments
Camilla Lincetto
on 28 Jan 2015
Commented: John D'Errico
on 28 Jan 2015
I need to solve the following equation which includes products between vectors and matrix:
>> F=@(x)(((x'*E)*((((Etrasp*i_covrend*E)/(Etrasp*i_covrend*uno))-((Etrasp*i_covrend*uno)/(unotrasp*i_covrend*uno)))^(-1))*(((i_covrend*E)/(Etrasp*i_covrend*uno))-((i_covrend*uno)/(unotrasp*i_covrend*uno))))-x)
>> fsolve(F,0)
Error using * Inner matrix dimensions must agree.
Error in @(x)(((x'*E)*((((Etrasp*i_covrend*E)/(Etrasp*i_covrend*uno))-((Etrasp*i_covrend*uno)/(unotrasp*i_covrend*uno)))^(-1))*(((i_covrend*E)/(Etrasp*i_covrend*uno))-((i_covrend*uno)/(unotrasp*i_covrend*uno))))-x)
Error in fsolve (line 241) fuser = feval(funfcn{3},x,varargin{:});
Caused by: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
I know that x must be a (10*1) vector and i'm sure that the dimensions of vectors and Matrix are correct. I don't know which command should I use to solve this equation and return a vector
0 Comments
Accepted Answer
John D'Errico
on 28 Jan 2015
Edited: John D'Errico
on 28 Jan 2015
"I know that x must be a (10*1) vector and i'm sure that the dimensions of vectors and Matrix are correct."
However, what you don't know is how to read the help for fsolve. How did you call fsolve?
>> fsolve(F,0)
So how does fsolve know that the unknown is a vector? What length vector? You told it only that the unknown is a SCALAR, essentially a vector of length 1. The starting value is 0, a scalar.
So while YOU know that the unknown is a vector of size 10x1, fsolve thinks it is a scalar unknown. You did tell it that after all.
Unless of course, you have the mind reading toolbox installed. Then you would type this on the command line:
set(0,'readMinds','on')
Sadly, I think that toolbox is still under beta test.
7 Comments
John D'Errico
on 28 Jan 2015
The warning message merely tells you that you used the wrong algorithm.
The error message suggests you made a mistake in the constraint function. If you read the help for fmincon, it tells you that the constraint function MUST return both equality and an inequality constraint result. If no inequalities are involved, then return an empty array for that argument.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!