You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
6 equation with 6 unknowns
2 views (last 30 days)
Show older comments
Hello everyone ,
I have 6 equations with 6 unknowns and ı dont know how to implement in matlab .Could you please help me ?
967.85 = L+V
611.6812=L*x(1) + V*y(1)
265.1909=L*x(2) +V*y(2)
x(1)*256.98=y(1)*1350.49
x(2)*1350.49=y(2)*556.29
(1-x(1)-x(2))*556.29=(1-y(1)-y(2))*256.98
Unknowns ; L ,V,x(1),x(2),y(1),y(2)
17 Comments
enis çoko
on 9 Apr 2020
syms L V x1 y1 x2 y2;
eqns = [L+V==967.85, L*x1+V*y1==611.6812, L*x2+V*y2==265.1909, x1/y1==1350.49/256.98, x2/y2==556.29/1350.49, (1-x1-x2)/(1-y1-y2)==256.98/556.29];
S=solve(eqns, [L V x1 y1 x2 y2]);
a=S.L;
b=S.V;
c=S.x1;
d=S.x2;
e=S.y1;
f=S.y2;
fprintf('%.2f\n',a)
fprintf('\n')
fprintf('%.2f\n',b)
fprintf('\n')
fprintf('%.2f\n',c)
fprintf('\n')
fprintf('%.2f\n',d)
fprintf('\n')
fprintf('%.2f\n',e)
fprintf('\n')
fprintf('%.2f\n',f)
I tried this method but one of the solution has minus sign.It must be positive but I can't see where I made a mistake
Torsten
on 9 Apr 2020
Edited: Torsten
on 9 Apr 2020
fsolve won't help - in my opinion, the rounding is the problem.
What you could do is search for a positive solution that satisfies the equations best possible. For this, try "lsqnonlin" and set the lower bounds of the variables to 0.
Ameer Hamza
on 9 Apr 2020
Edited: Ameer Hamza
on 9 Apr 2020
enis, you mentioned "I tried this method but one of the solution has minus sign.It must be positive"
Do you know for sure that all the solutions of these equations are positive and solutions given by the solve() function are wrong? Or is this a requirement that the solutions should be positive?
Ameer Hamza
on 9 Apr 2020
enis, yes, from the physical interpretation, it makes sense that the solution must be positive? Can you show us the equations in mathematical form? Because if you put the solution given by MATLAB into your equations, it will satisfy all the equations. I suspect there might be an issue in writing the equations in MATLAB syntax.
Ameer Hamza
on 10 Apr 2020
enis, please recheck your hand derivations. The negative solution does satisfy these equations. There may be a mistake in these equations, or there is some error in the numeric coefficients.
Answers (0)
See Also
Categories
Find more on Variables 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!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)