zero(s) of a nonlinear implicit function

3 ビュー (過去 30 日間)
Ali Kiral
Ali Kiral 2025 年 3 月 15 日
編集済み: Ali Kiral 2025 年 5 月 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 Center および File ExchangeSymbolic Math Toolbox についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by