Finding an angle in a trigonometric function using 2 equations

2 Ansichten (letzte 30 Tage)
ERCAN UMUT
ERCAN UMUT am 23 Mär. 2024
Bearbeitet: ERCAN UMUT am 23 Mär. 2024
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 Kommentare
Dyuman Joshi
Dyuman Joshi am 23 Mär. 2024
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."
In order to use solve or vpasolve, you need to specify the variable (to solve for) as a symbolic variable. See - syms. And you need to solve for each equation separately.
Also, as this equation is clearly non-linear, linsolve will not work here.
ERCAN UMUT
ERCAN UMUT am 23 Mär. 2024
Bearbeitet: ERCAN UMUT am 23 Mär. 2024
Oh, sorry about the insufficient information. Of course I specified gamma and used sym. I thought these equations would be enough to explain the problem I have. I updated the first message.
Yes, problem is non-linear and I wanted to solve it without any numerical scheme. Is it possible?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Dyuman Joshi
Dyuman Joshi am 23 Mär. 2024
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
out = 1x21
-227.2711 -226.9536 -226.9409 -226.9413 -226.9416 -226.9418 -226.9420 -226.9421 -226.9423 -226.9424 -226.9425 -226.9426 -226.9427 -226.9428 -226.9429 -226.9430 -226.9430 -226.9431 -226.9432 -226.9433 -226.9434
pressureratio = 1+(2*k)/(k+1)*((M*sind(out)).^2-1)
pressureratio = 1x21
29.7585 29.4524 29.4402 29.4406 29.4408 29.4410 29.4412 29.4414 29.4415 29.4416 29.4417 29.4418 29.4419 29.4420 29.4421 29.4422 29.4422 29.4423 29.4424 29.4425 29.4425
  3 Kommentare
ERCAN UMUT
ERCAN UMUT am 23 Mär. 2024
You are right and I am so sorry about the sloppiness. I had spent so much time with the code I wrote them again and again, and When I had the time I wanted post it in here so I wrote them again in a hurry which was not correct form of the equation. So sorry about that.
Your assumption is kinda correct, because MATLAB was giving error in the usage of * and ^ so I had to put a dot in front of them and when I made the changes I probably did some copy paste errors. The equation can be seen in the figure below.
I would really appreciate the help. Thank you again.
ERCAN UMUT
ERCAN UMUT am 23 Mär. 2024
Bearbeitet: ERCAN UMUT am 23 Mär. 2024
Thank you so much for the answer. I used the code after fixing the equation. It looks like it works but I will be able to check it tomorrow.
Thank you again.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Particle & Nuclear Physics 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