How do I limit angle values in my equations to between 0-90°?
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi there,
I'm including a simplified version of my code, along with the graph I'm getting from it. What I'm trying to do is to limit the angle m (or m_) to between 0 and 90 degrees only. Can anyone help?
clc
t=[0:0.01:1];
for j=1 : 101
syms m
m_ = solve(sind(m)==t(j), m);
y = zeros(numel(t), numel(m_)); % pre-allocation
y(j, :)=m_*30+5;
hold on
plot (t, y)
end
0 comentarios
Respuestas (3)
Alan Stevens
el 27 de Sept. de 2020
This does it
t=[0:0.01:1];
for j=1 : 101
m_ = rad2deg(asin(t(j)));
y = zeros(numel(t), numel(m_)); % pre-allocation
y(j, :)=m_*30+5;
hold on
plot (t, y)
end
0 comentarios
Jack Cross
el 27 de Sept. de 2020
2 comentarios
Alan Stevens
el 27 de Sept. de 2020
rad2deg doesn't necessarily keep the angles between 0 and 90. but asin(x) where x is anything from 0 to 1, does (well, it keeps it between 0 and pi/2).
If you supply the other variable values, range of t etc. I'll have a look at your more complicated expression.
Jack Cross
el 27 de Sept. de 2020
5 comentarios
Alan Stevens
el 27 de Sept. de 2020
After playing around a bit I managed to fill in the lower end, down to t = 0.01, as follows:
dl = 0.3;
t= 0.01:0.01:2.47;
theta_ = zeros(numel(t),1);
for j=1 : numel(t)
if t(j)<0.05
theta0 = 1;
elseif t(j)<0.1
theta0 = 8;
else
theta0 = 90;
end
theta_(j) = fzero(@zerofn,theta0,[],t(j));
end
y= dl*sind(theta_);
hold on
plot (t, y),grid
xlabel('t'),ylabel('y')
function F = zerofn(theta,t)
L=0.01;
g=9.81;
m=0.85;
T1=(L+0.5)*m*g;
T2=(L+0.5)*m*g;
W=m*g;
dc=0.15;
dt=0.3;
dl=0.3;
Fy=L*g;
F = sqrt((2*dl*sind(theta)) ...
/(Fy + (T1*dt/(m*dl)+T2*sind(theta)/m+W*dc/(m*dl)) ...
*cosd(theta)*sind(90-theta)))-t;
end
The resulting graph now looks like:
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!