Filter löschen
Filter löschen

Using several variables with fsolve

2 Ansichten (letzte 30 Tage)
Nate
Nate am 16 Apr. 2012
I have a 2x1 force matrix that I'd like to solve for 0. The problem right now is that it is completely made up of 6 variables and I'd like matlab to return solutions for 2 of the variables.
fsolve doesn't seem to be able to deal with this many variables.
For the matrix:
Ft=[3*Yc*k*exp(i*omega*t) - (23*L*k*theta*exp(i*omega*t))/20 - (5*L*Yc*m*omega^2*exp(i*omega*t))/2 ;
(443*L^2*k*theta*exp(i*omega*t))/400 - (23*L*Yc*k*exp(i*omega*t))/20 - (99*L^3*m*omega^2*theta*exp(i*omega*t))/160]
solve(Ft==0,Yc,theta)
I've even tried using:
solve(Ft(1,:)==0,Ft(2,:)==0,Yc,theta)
as well as just even:
solve(Ft(1,:)==0,Yc)
I would like to return solutions for Yc and theta.
The error I'm receiving for all methods is the following:
??? Error using ==> char
Conversion to char from logical is not possible.
Error in ==> solve>getEqns at 165
vc = char(v);
Error in ==> solve at 67
[eqns,vars] = getEqns(varargin{:});

Antworten (2)

Walter Roberson
Walter Roberson am 16 Apr. 2012
We are going to need to see your call to solve() and the equations you are passing in.
You would get the above error if you are passing in a logical value, which could (for example) happen if you use "==" in your equations.
The general solution for the matrix you show is Yc = 0, theta = 0. There are additional solutions such as Yc = 0, L = 0, theta = anything.
  2 Kommentare
Nate
Nate am 17 Apr. 2012
added information, thank you for assisting.
Walter Roberson
Walter Roberson am 17 Apr. 2012
Leave out the "== 0" . That is converting your inputs to boolean. Solving for the expressions being equal to zero is the default.

Melden Sie sich an, um zu kommentieren.


Sargondjani
Sargondjani am 17 Apr. 2012
yes, walther is right (of course), you need to keep the syntax for fsolve:
YOur objective is: Ft=0, so pass as objective just 'Ft'.
BUT you have to write it as a function. First you have to specifiy the parameters, and then the function:
par1=...
par2=...
myfunction=@(var1,var2,...,var_last)[...;...];
on the ... in the [] you can write your orginal thingy, with the parameters and variables.
then you solve with fsolve:
fsolve(myfunction,[var1_0,var2_0,...var_last_0])
this is the format you should be using. BUT you have to understand that fsolve will only give 1 solution! in your case, there infinitely many solutions, so you need to work on that first (as the other poster was saying)

Kategorien

Mehr zu Performance and Memory finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by