plot([0 0], [-sqrt(a)+sqrt(b) sqrt(a)+sqrt(b)],'o')
Are you sure it's correct? May be this?
plot([0 0], [-sqrt(a^2+b^2) sqrt(a^2+b^2)],'ro')
Or this?
plot([0 0], [-a a],'go')
Please define what are foci points?
% Program to plot the hyperbola
% y^2/a^2 - x^2/b^2 = 1
% The hyperbolae are open up/down, so that x is the independent variable
% for plotting. (Using the form x^2/a^2 - y^2/b^2 = 1 requires that y be
% the independent variable, which is awkward programming-wise.)
clear % all variables
figure(1), hold off % start a new figure
set(gca,'FontSize',14) % adjust fontsize
xmax = 30; ymax = 20;
x = linspace(-xmax,xmax,1001); % array of x values for plot : This function generates vector with 1001 points equally distributed between -xmax and xmax.
%1001 is probably to have 500 points on one side (>0), 500 on another side (<0) and to include 0 itself. So you will have
%more natural numbers.
a = 5; b = 3;
y=sqrt(((x.^2)./(b^2)+1).*a^2); % corresponding y values
plot(x,y)
hold on % add to current plot
plot(x,-y) % Plot other half of hyperbola
axis([-xmax xmax -ymax ymax]) % specify axis limits
xlabel('x')
ylabel('y')
title(['Hyperbola $y^2/a^2 - x^2/b^2 = 1$; $a$ = ', num2str(a), ...
', $b$ = ', num2str(b),'; (WR 1/21/08)'],'Interpreter','latex')
% Add axes
plot([0 0],[-ymax ymax],'k') % y axis (black line - k)
plot([-xmax xmax],[0 0],'k') % x axis
% Program to plot the elipse
% y^2/a^2 - x^2/b^2 = 1
y=sqrt(((-x.^2)./(b^2)+1).*a^2); % corresponding y values
plot(x,real(y))
hold on % add to current plot
plot(x,-y) % Plot other half of elipse
axis([-xmax xmax -ymax ymax]) % specify axis limits
xlabel('x')
ylabel('y')
title(['Hyperbola and elipse $y^2/a^2 + x^2/b^2 = 1$;$y^2/a^2 - x^2/b^2 = 1$; $a$ = ', num2str(a), ...
', $b$ = ', num2str(b),';'],'Interpreter','latex')
% Add axes
plot([0 0],[-ymax ymax],'k') % y axis (black line - k)
plot([-xmax xmax],[0 0],'k') % x axis
f1=sqrt(a.^2+b.^2);
f2=-(sqrt(a.^2+b.^2));
plot([0 0],[f1 f2],'.')
text(0,f1,'\leftarrow +d','VerticalAlignment','middle','HorizontalAlignment','left')
text(0,f2,'\leftarrow -d','VerticalAlignment','middle','HorizontalAlignment','left')
Title | # Comments | Views | Activity |
---|---|---|---|
zeroFront challenge | 7 | 71 | |
upcasting down casting object remains same but refernece changes | 8 | 56 | |
sumDigits challenge | 7 | 61 | |
PHP question(s) about order of output | 9 | 43 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
20 Experts available now in Live!