I would like to know how I could plot a hyperbolic function of x and y.
3 views (last 30 days)
Show older comments
Mehmet Arslan
on 25 Oct 2020
Edited: Mehmet Arslan
on 26 Oct 2020
I was recently given an assignment for my intro to LaTeX class where I needed to plot the given function: x^(2)/9 - y^(2)/4 = 1. I know that this function is a hyperbola, but I can't seem to get it to work properly. The assignment also asked us to generate a list of no more than 6 values to test. I used the linspace function to come up with an evenly spaced matrix for my x values. This is my code:
function graph_1
clear;
x = linspace(-10,10);
y1 = (2*sqrt(x.^(2)/9)/3);
y2 = -(2*sqrt(x.^(2)/9)/3);
figure(1); clf;
plot(y1, y2, 'b')
set(gca, 'fontsize', 12)
title('(x^2)/9 - (y^2)/4 = 1')
grid on
print(figure(1), '-dpng') % They also asked that we save the figure in documents and then use LaTeX to reference it later.
end
2 Comments
John D'Errico
on 25 Oct 2020
Edited: John D'Errico
on 25 Oct 2020
Do you see that these lines:
y1 = (2*sqrt(x.^(2)/9)/3);
y2 = -(2*sqrt(x.^(2)/9)/3);
do NOT allow you to solve that equation fot y? They simply do not correspond to the equation of the hyperbola you have given us. So try again. Basic algebra here, no question about MATLAB.
So write the equation on paper, and solve for y.
Oh, by the way, if you were asked to generate no MORE than 6 points, why would use use 21 points on that curve?
Accepted Answer
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!