Can someone help me how to calculate theta?

a and b are variables calculated by measured values.
I dont know how should I define theta:
Error
Unrecognized function or variable 'theta'.
S = solve ((((a+b)*theta)/(theta^2 - (a*b))*tan_theta), theta)

5 Comments

Is tan_theta also known, or did you mean to write tan(theta) ?
Somethimes it helps to plot things numerically.
% Demo by Image Analyst.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 16;
fprintf('Beginning to run %s.m ...\n', mfilename);
theta = linspace(-1.2, 1.2, 400);
a = linspace(-pi, pi, 400);
mina = min(a)
maxx = max(a)
allb = linspace(-pi, pi, 9)
for k = 1 : length(allb)
b = allb(k);
subplot(3, 3, k);
plot(theta, tan(theta), 'b-', 'LineWidth', 2);
grid on;
hold on;
y = (a + b) .* theta ./ (theta.^2 - a * b);
plot(theta, y, 'r-', 'LineWidth', 2)
caption = sprintf('b = %.2f, a = [%.2f, %.2f]', b, mina, maxx);
title(caption);
xlabel('theta')
end
y = (a + b) .* theta ./ (theta.^2 - a * b);
if theta is 0 and a and b are finite then the numerator is 0. If neither a nor b are 0 then the denominator would be nonzero for this case. Therefore y would have to be 0. tan(0) is 0. So except when a or b are 0, theta = 0 is a solution. However none of your plots show it as a solution.
a and b are values between (0.001-1.00)
tan (theta) is unknown as well
the error is "unrecognized function or variable theta"
I believe the equation is solvable since theta is the only unknown!
(tan(theta) = (a + b) .* theta ./ (theta.^2 - a * b)
What happens if, hypothetically, theta were 0?
tan(theta) = (a+b) * theta /(theta^2 - a*b)
tan(0) is 0
0 = (a+b) * 0 / (0^2 - a*b)
0 = 0 * (a+b) /(-a*b)
if a*b is not 0 then the denominator is not 0. 0 / nonzero is 0. So left side is 0 and right side is 0.
Therefore theta = 0 is a solution whenever neither a nor b is 0.

Sign in to comment.

Answers (2)

try fsolve with an initial guess.
I am assuming you meant to write tan(theta) instead of tan_theta
intial_guess =1;
S = fsolve(@(theta) (((a+b)*theta)/(theta^2 - (a*b))*tan(theta)), initial_guess)

1 Comment

I got this error!
No solution found.
fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
value of the function tolerance.
<stopping criteria details>
Unrecognized function or variable 'theta'.
-- logically the equation should be solved for theta , I think basically something is wrong with my MATLAB code, which I cannt figure it out. fsolve is not working!

Sign in to comment.

The solution is theta = 0 unless a or b are 0.

6 Comments

a = randn()
a = 1.0368
b = randn()
b = -0.3255
syms theta
eqn = tan(theta) == (a+b)*theta/(theta^2 - a*b)
eqn = 
E2 = lhs(eqn) - rhs(eqn)
E2 = 
fplot([E2,0], [-20 20])
fplot([E2, 0], [-1 1])
theta = 0 is not the only solution, but it is a solution.
This all depends upon the equation shown in https://www.mathworks.com/matlabcentral/answers/1574133-can-someone-help-me-how-to-calculate-theta#comment_1805933 being the correct equation. The question you posted originally was different:
a = rand()
a = 0.9761
b = rand()
b = 0.8016
syms theta
E2 = (((a+b)*theta)/(theta^2 - (a*b))*tan(theta))
E2 = 
fplot([E2, 0], [-10 10])
fplot([E2, 0], [-1 1])
we can see by inspection that this has a 0 when theta is 0, or when tan(theta) is 0, or when theta is infinite.
I don't know how did you draw these graphs, but when I define theta as a sym/s or symbolic it will not calculate theta. I need to calculate theta from the equation.
using this code will give me the symbolic "theta" in the rest of following equation in my code!!
eqn =
tan(theta) == (894987427786373*theta)/(4503599627370496*(theta^2 - 710587193844941/72057594037927936))
I showed how to plot:
E2 = lhs(eqn) - rhs(eqn)
fplot([E2,0], [-20 20])
E2 is the difference between the left hand side and the right hand side. The places where E2 is 0 are the places where the two sides balance out
can you show the value for theta?
eqn = str2sym('tan(theta) == (894987427786373*theta)/(4503599627370496*(theta^2 - 710587193844941/72057594037927936))')
eqn = 
E2 = lhs(eqn) - rhs(eqn)
E2 = 
fplot([E2, 0], [-1 1])

Sign in to comment.

Categories

Asked:

on 28 Oct 2021

Commented:

on 3 Nov 2021

Community Treasure Hunt

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

Start Hunting!