- https://www.mathworks.com/matlabcentral/answers/514344-symbolically-solving-a-multi-variable-system-of-three-equations-for-three-variables
- https://www.mathworks.com/matlabcentral/answers/66033-solving-3-equations-with-3-unknowns
Solving 3 equations having 3 variables in terms of other variables
3 views (last 30 days)
Show older comments
I was solving a catenary curve when 2 points and length L is known.
Genral equation of catenary is y == c1/m/g*cosh(m*g/c1*(x+c2))-lambda/c1 where c1, c2 and lambda are unknown constants. 3 conditions given to solve the equation are
1) y=y1 when x=x1
2) y=y2 when x=x2
3) L = c1/m/g*(sinh(m*g/c1*x2+c2)-sinh(m*g/c1*x1+c2))
So, I used first 2 condition to get eq1 and eq2 then I tried to solve eq1, eq2 and eq3 for c1, c2 and lambda in terms of variable m g L x1 x2 y1 y2 so that I would be able to calculate a catenary when the values of latter variables are known.
Here is the code. It is giving an error. I was told that these equations can be solved numerically but I want an expression in terms of m g L x1 x2 y1 y2. Is there a way to get an expression? How it can be done in Matlab?
clear
clc
syms c1 c2 lambda m g x y x1 x2 y1 y2 L
eq1 = y1 == c1/m/g*cosh(m*g/c1*(x1+c2))-lambda/c1
eq2 = y2 == c1/m/g*cosh(m*g/c1*(x2+c2))-lambda/c1
eq3 = L == c1/m/g*(sinh(m*g/c1*x2+c2)-sinh(m*g/c1*x1+c2))
[solc1, solc2, sollambda] = solve([eq1 eq2 eq3],[c1 c2 lambda])
0 Comments
Answers (1)
Maneet Kaur Bagga
on 15 Feb 2024
Hi,
As per my understanding you want to find the parameters of a curve given two points on the curve and the length of the curve between those points. Please refer to the below code using the "Symbolic Math Toolbox" as a possible workaround for the same:
syms c1 c2 lambda m g x1 x2 y1 y2 L
% Define the equations based on the conditions
eq1 = y1 == c1/m/g*cosh(m*g/c1*(x1+c2))-lambda/c1;
eq2 = y2 == c1/m/g*cosh(m*g/c1*(x2+c2))-lambda/c1;
eq3 = L == c1/m/g*(sinh(m*g/c1*(x2+c2))-sinh(m*g/c1*(x1+c2)));
% Attempt to solve the equations symbolically
sol = solve([eq1, eq2, eq3], [c1, c2, lambda], 'ReturnConditions', true);
% Display the solution
sol.c1
sol.c2
sol.lambda
If the solution is not found, it will return an empty symbolic array or a warning message. In that case, you will need to resort to numerical methods to estimate the values of "c1", "c2" , and "lambda" for specific numerical inputs of m, g, L, x1, x2, y1, and y2.
Please refer to the MATLAB Answers below for a similar workaround:
Please refer to the MATLAB Documentation of "fsolve" function for further understanding:
Hope this helps!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!