Multiple equations solving in MATLAB

9 views (last 30 days)
I have 10 equations and 10 variables. 6 of them are non-linear and 4 of then are linear . I have 2 constraints. I have tried several programming .nothing is working out for me.
i was wondering if anyone can tell me how to solve it in MATLAB
  4 Comments
Golam Ismot Ara taposhe
Golam Ismot Ara taposhe on 31 Jan 2020
Hi walter
Is there any way I can solve it in MATLAB?
I was wondering if you can give any suggestion here?
Thank you for your time
Golam Ismot Ara taposhe
Golam Ismot Ara taposhe on 14 Feb 2020
Hi walter
I have solved it, thank you so much for your constant support
best
Taposhe

Sign in to comment.

Answers (2)

Alex Sha
Alex Sha on 28 Jan 2020
Hi, Golam, post out your problem, we may try.
  28 Comments
Golam Ismot Ara taposhe
Golam Ismot Ara taposhe on 11 Feb 2020
Hi Walter
From vapsolve it took almost 5 hours to get some values.
I got several warning values like below and multiple values of each vaiables (I have given one of them to show you).
{Warning: Solution '[x11 = -0.38750367826943393346203707487446, x22 =
-0.00000060583325942090259608703097820327, x33 =
-0.000038650066836096378956219616167947, x44 = -0.0000048908827834088449488126789731625,
x12 = 0.85110289647020175449525875148945, x13 =
0.37292297133288576681275288927368, x14 = 0.0027533507357803688041407060780671, x24 =
0.16090647871265852412483387878892, x23 =
0.000010135483658517192456190547613278, x34 = -0.00014800768287208782214890388479803]'
seems to be affected by some numeric instability.
Inserting this solution into equation 'x12^2 - (6626207954368463*x11*x22)/2147483648 = 0'
produces the residue
'0.00000000000030833038535512130740942027139926'.}..............................................................
X11=
3.8738121895266076426113797703788e+74
3.6665527467324870120747140518347e+69 + 4.3567273814115433908181896380624e+70i
3.6665527467324870120747140518347e+69 - 4.3567273814115433908181896380624e+70i
1.2093861453901211537782805512659e+101
0.000053882931343728240927855813790698
0.000053882706767122569158490778389023
0.000053807955312050678830801654097808
0.0000538077304413047952097862083875
-7.3854207307736464976581835531054e+74
0.000033176145565362070576015087524794
0.000033176338952970457036913395663678
0.000033109103226504987910799623088257
0.000033109296589075267193735647291267
2.8254024107173870504811031811197e+70 - 5.9311882667731407548267433191443e+70i
2.8254024107173870504811031811197e+70 + 5.9311882667731407548267433191443e+70i
1.7685725013650819705301561897085e+70 + 1.8063164266990928662426900108303e+70i
Golam Ismot Ara taposhe
Golam Ismot Ara taposhe on 11 Feb 2020
Hi Walter
like you said fsolve() gave me a good result but one variable is negative. I tried to use your flow this restricted_structure i am unfamilier and giving me error.
I was wondering if you can help me to figure this out
thank you so much for your time
>>F10_restricted_struct = vpasolve(F10fun, abs(F10sol), vars, repmat([0 1], nvars, 1));
Error using sym.getEqnsVars (line 32)
Arguments must be symbolic objects.
Error in sym/vpasolve (line 132)
[eqns,vars] = sym.getEqnsVars(varargin{1:N});
>> F10_restricted = double(cell2mat(struct2cell(F10_restricted_struct)));
Unrecognized function or variable 'F10_restricted_struct'.
>> F11min = fmincon(residue11, F10sol, zeros(1,nvar));
Unrecognized function or variable 'residue11'.
Did you mean:
>> F11min = fmincon(residue, F10sol, zeros(1,nvar));
Not enough input arguments.
Error in residue (line 81)
u = u(:).'; v = v(:).'; k =[];

Sign in to comment.


Samatha Aleti
Samatha Aleti on 28 Jan 2020
Hi,
You may use “fsolve” and “solve” functions to solve system of non-linear equations and linear equations respectively. Refer the following documentation links on detailed explanation on using “fsolve” and “solve”:
  6 Comments
Walter Roberson
Walter Roberson on 13 Feb 2020
Change
[F11min, F11fval] = fmincon(residue11, F10_restricted, [], [], [], [], zeros(1,nvars), [], [], options); %zeros is lb
to
empty = zeros(0,0);
A = empty;
b = empty;
Aeq = empty;
beq = empty;
lb = zeros(1,nvars);
ub = empty;
nlcon = empty;
[F11min, F11fval] = fmincon(residue11, F10_restricted, A, b, Aeq, beq, lb, ub, nlcon, options);
That is exactly equivalent for calling purposes, but it documents more clearly what the various parameters are standing for.
To clarify: the [] in the function call were not placeholders indicating values that you had to fill in: instead [] is the empty array, 0 x 0, and using it signals to MATLAB that you do not want to supply a value for the parameter. For example, [] in the A and b locations indicates that you have no linear constraints to work with.
In some contexts, [] in a MATLAB call indicates that you want the default to be supplied, instead of indicating that you want to skip the parameter. For example, if you had
x = rand(6,5);
reshape(x, 2, [], 5)
would signal to MATLAB that MATLAB should calculate how many elements are in x, and divide by 2 and 5, and fill in what is left in place of the [] -- so 30 / 2 / 5 giving 3, making the call equivalent to reshape(x, 2, 3, 5)
Whether [] signals to a routine to de-activate functionality (like fmincon) or to provide default functionality or values (like reshape) is up to the routine. If you mentally translate it as, "I don't want to bother putting this in" and expecting the routine to do something "sensible" then that will be pretty close.
Golam Ismot Ara taposhe
Golam Ismot Ara taposhe on 14 Feb 2020
hi walter
thank you so much for your help. will be greatful for this

Sign in to comment.

Categories

Find more on Signal Reception and Recovery 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!