solving equations with vector as the unknown variable
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
John D'Errico
2015-1-28
编辑:John D'Errico
2015-1-28
"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 个评论
John D'Errico
2015-1-28
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!