zero(s) of a nonlinear implicit function

1 次查看(过去 30 天)
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?

采纳的回答

Walter Roberson
Walter Roberson 2025-3-16
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 个评论
Walter Roberson
Walter Roberson 2025-3-16
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 2025-3-16
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 = 

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by