zero(s) of a nonlinear implicit function

1 Ansicht (letzte 30 Tage)
Ali Kiral
Ali Kiral am 15 Mär. 2025
Bearbeitet: Ali Kiral am 30 Mai 2025
I want to find the roots of an implicit function whose dependant variable is impossible to isolate. In particular, I want to find an array of outputs for a given array of inputs. That function is
1.5786+3*cosd(theta4-1.0714*cosd(theta2)-cosd(theta4-theta2)=0
Here, theta2 is the input and theta4 is the output. A function m-file:
function theta4 = fourbar(theta2)
theta2=0:0.5:360;
for i =1:length(theta2)
1.5786+3*cosd(theta4(i))-1.0714*cosd(theta2(i))-cosd(theta4(i)-theta2(i))
end
In the command prompt with an initial guess of 0.01 does not work:
fsolve(@fourbar,0.01)
How can I pass the elements of theta2 to the function 'fourbar' and then solve for theta4 in another array?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 16 Mär. 2025
In particular, I want to find a array of outputs for a given array of inputs.
That is not possible using fsolve() -- not unless you use a for loop or arrayfun to process one at a time.
fsolve() is strictly for a single output given a vector of input parameters.
  2 Kommentare
Walter Roberson
Walter Roberson am 16 Mär. 2025
syms theta2 theta4 real
C1 = sym(1.0714);
eqn = sym(pi)/2+3*cosd(theta4)-C1*cosd(theta2)-cosd(theta4-theta2)
eqn = 
for K = 1 : 50
result(K) = vpasolve(eqn, [theta2, theta4], [rand()*360; randn()]);
end
T2 = [result.theta2];
T4 = [result.theta4];
mask = T2 >= 0 & T2 <= 360;
T2 = T2(mask);
T4 = T4(mask);
sortrows([T2; T4].')
ans = 
Walter Roberson
Walter Roberson am 16 Mär. 2025
syms theta4 real
theta2 = sym(339.85);
C1 = sym(1.0714);
eqn = sym(pi)/2+3*cosd(theta4)-C1*cosd(theta2)-cosd(theta4-theta2)
eqn = 
for K = 1 : 50
result(K) = vpasolve(eqn, [theta4], [randn()]);
end
T4 = [result];
sortrows(T4.')
ans = 

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by