Finding an angle in a trigonometric function using 2 equations
古いコメントを表示
Hello everybody,
I am trying to find beta angle in the eqns. below. I tried "vpasolve, linsolve, solve" but none of them seem to work.
syms M gamma
M=7.0;
gamma=1.3;
x=0:(0.01):2;
dy=((2.25+4*x-x.^2).^(-1/2)).*(2-x);
beta = solve(dy==2/cotd(beta)*((M.^2*sin(beta.^2)-1)/(M.^2*(gamma+cos(beta)^2)+2)), beta)
pressureratio= 1+(2*gamma)/(gamma+1)*((M*sind(beta)).^2-1)
I always end up getting a different error message. Is there a way to find beta?
2 件のコメント
Dyuman Joshi
2024 年 3 月 23 日
You have not provided M and gamma values.
Also, gamma is a inbuilt function in MATLAB. Best to not name variables (or scripts for that matter) using function names. You could use k instead.
"I tried "vpasolve, linsolve, solve" but none of them seem to work."
ERCAN UMUT
2024 年 3 月 23 日
編集済み: ERCAN UMUT
2024 年 3 月 23 日
回答 (1 件)
As you are solving for beta, you have to define beta as a symbolic variable.
Also, I have reduced the step size in x, as the variation for smaller values of x (and thus dy) is minute.
syms beta
M=7.0;
k=1.3;
x=0:(0.1):2;
dy=((2.25+4*x-x.^2).^(-1/2)).*(2-x);
n = numel(x);
%Pre-allocate output variable
out = zeros(1,n);
%Svoling equations separately
for r = 1:n
eqn = dy(r)==2/cotd(beta)*((M.^2*sin(beta.^2)-1)/(M.^2*(k+cos(beta)^2)+2));
out(r) = vpasolve(eqn, beta);
end
out
pressureratio = 1+(2*k)/(k+1)*((M*sind(out)).^2-1)
3 件のコメント
While you might be on the correct path, I think you are trying to solve a HIGHLY flawed question.
Look at this one line:
syms beta
M=7.0;
k=1.3;
% Note I have just renamed the left hand side here.
% This was done purely for display purposes.
dyr = 2/cotd(beta)*((M.^2*sin(beta.^2)-1)/(M.^2*(k+cos(beta)^2)+2))
Do you see any almost certain problems in that line?
First, we see beta used inside both the sine and cosine functions, that STRONGLY implies beta has units of radians. However, then we look at the cotangent call. Use of cotd implies beta has units of degrees. You cannot have things both ways.
Next, I STRONGLY fear that a mistanke has also been made in another place, given the sloppiness in the use of degrees versus radians. First, I see sin(beta.^2), but then I see cos(beta).^2.
I think it most likely that ONE of those terms has the square placed in the wrong position.
Given the above errors, I would suggest a correct answer is impossible until the issues with the formulas have been corrected. First, I would just go all the way with radians or degrees. Below I'll assume radians, as it makes the formulas simpler to read. Since you are solving for beta in the end, you can always correct to degrees at the very end.
As well, I'll assume it is more likely that sin(beta) was squared, and the square is not inside the sine function. The former will be far more common. So I THINK this is what you may have wanted to write:
dyr = 2/cot(beta)*((M.^2*sin(beta).^2-1)/(M.^2*(k+cos(beta)^2)+2))
Can you solve that expression directly using solve now? You might actually be able to do so now. Since the true form of that expression is unknown, here just a wild guess on my part, I cannot take things any further.
ERCAN UMUT
2024 年 3 月 23 日
ERCAN UMUT
2024 年 3 月 23 日
編集済み: ERCAN UMUT
2024 年 3 月 23 日
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


