Please help, the value of a function is changing with the domain.
2 views (last 30 days)
Show older comments
I am required to create a graph of 4 different equations, y1, y2, y3, y4 shown below, where the only difference is this R value. When I start with a domain of theta going from 0-90 degrees (the first graph) you can clearly see a distinction between all 4 equations. When I change the domain from 0-180 degrees, all 4 equations result in identical outputs that overlap. It seems as I get closer to a domain of 180 degrees, the equations become more and more similar. Does anyone know what is causing this problem? Thanks in advance.
if true
R1 = 3;
R2 = 3.5;
R3 = 4;
R4 = 10;
theta = 0:1:180;
y1 = ((pi/2)*sin(theta*pi/180)*(1+ ((cos(theta*pi/180))/(((R1^2) - (sin(theta*pi/180).^2)).^0.5))));
y2 = ((pi/2)*sin(theta*pi/180)*(1+ ((cos(theta*pi/180))/(((R2^2) - (sin(theta*pi/180).^2)).^0.5))));
y3 = ((pi/2)*sin(theta*pi/180)*(1+ ((cos(theta*pi/180))/(((R3^2) - (sin(theta*pi/180).^2)).^0.5))));
y4 = ((pi/2)*sin(theta*pi/180)*(1+ ((cos(theta*pi/180))/(((R4^2) - (sin(theta*pi/180).^2)).^0.5))));
figure; hold all;
plot(theta, y1, theta, y2, theta, y3,theta, y4)
Code:

theta = 0:1:90 :

theta = 0:1:180 :

theta = 0:1:170 :

0 Comments
Accepted Answer
David Goodmanson
on 13 Feb 2017
Edited: David Goodmanson
on 13 Feb 2017
Hello Joshua, For each variable, try this with extra dots in the locations shown. This is because it appears that you want term-by-term multiplication or division of your vector elements, not some kind of matrix multiplication or division.
y1 = ((pi/2)*sin(theta*pi/180).*(1+ ((cos(theta*pi/180))./(((R1^2) - (sin(theta*pi/180 ...
^ ^
Interesting effect.
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!