solving equations with vector as the unknown variable
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Camilla Lincetto
el 28 de En. de 2015
Comentada: John D'Errico
el 28 de En. de 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 comentarios
Respuesta aceptada
John D'Errico
el 28 de En. de 2015
Editada: John D'Errico
el 28 de En. de 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 comentarios
John D'Errico
el 28 de En. de 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.
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!