MATLAB Answers

Issue with sine graph

2 views (last 30 days)
Kaylee Chavez
Kaylee Chavez on 22 May 2021
Edited: DGM on 23 May 2021
I am having some difficulty graphing a function using sine. I graph it and it is either a y =x type graph or just lines. If someone could provide some direction that would be great.
%Oblique Balance Script
figure('Name','Team A Graphs');
clf;
%%Weight Ratio
subplot(2,1,1)
t=[0:0.01:180]
r = sind(30 + t) ./ sind(30 - t);
plot(t, r);
area(t,r,'FaceColor',[.8,.9,1.0]);
%Weight Graph
title('Weight ratio')
xlabel('Angle change')
ylabel('Ratio')

Answers (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 22 May 2021
Hi,
If you're trying to plot the weight ratio explained in your previous post, that has to be up to 30 degrees.
Thus, you'd need to make some corrections in your code while selecting the range t values, e.g.:
...
t=0:.25:29;
...
Note that at t=30, y goes to inf.
Good luck.
  1 Comment
DGM
DGM on 23 May 2021
For emphasis:
t=[0:0.01:180];
r = sind(30 + t) ./ sind(30 - t); % the denominator goes to zero.
plot(t, r);
area(t,r,'FaceColor',[.8,.9,1.0]);
ylim([-100 100]) % so explicitly limit y limits
I have no idea what this plot means conceptually, but that's why it looks like it does.

Sign in to comment.


VBBV
VBBV on 22 May 2021
Edited: VBBV on 22 May 2021
%if true
%Oblique Balance Script
figure('Name','Team A Graphs');
clf;
%%Weight Ratio
subplot(2,1,1)
t=[0:0.01:180]*pi/180;% change here
r = sind(30 + t) ./ sind(30 - t);
plot(t, r);
area(t,r,'FaceColor',[.8,.9,1.0]);
%Weight Graph
title('Weight ratio')
xlabel('Angle change')
ylabel('Ratio')
Input variable t require a change in rad to deg
  1 Comment
DGM
DGM on 23 May 2021
OP is using sind(), not sin(), and the offsets are in degrees as well. Changing everything to radians doesn't address the issue.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by