I need to fix this in order to graph a parabola's reflection property!!

2 visualizaciones (últimos 30 días)
Courteney Charles
Courteney Charles el 11 de Jun. de 2019
Comentada: Rik el 18 de Jun. de 2019
function ParaReflecPropM(a,b,c,d,p,N)
% p is focal distance from vertex
x=linspace(a,b); %generates a row vector y of 100 points linearly spaced between and including a and b.
y=(x.^2)/4*p; %general equation of a parabola
plot(x,y)
hold on;
for n=c:N:d %partition points from c to d, increasing by increments of N
plot([0 n],[p, y(n)]) %plots a line from the focus (0,p) to a point (x(n),y(n)) on the parabola
plot([n,n],[y(n),y(end)]) %plots the vertical line from the point on the parabola to infinity
end
ax=gca;
ax.XAxisLocation='origin';
ax.YAxisLocation='origin';
title('Reflection Property of Parabolas')
fprintf('There you have it! The special reflection property for parabolas!\n')
end
% can someone please help? I'm getting an error in line 8, but I don't know how
% to better format that part. This is what the error says:
% Array indices must be positive integers or logical values.
  3 comentarios
Courteney Charles
Courteney Charles el 12 de Jun. de 2019
Never mind!! I figured it out. Thanks!
Rik
Rik el 18 de Jun. de 2019
@Darova, shouting is not automatically the same as showing disrespect. It is helpful for Courteney to know some people view double exclamation points as a sign of disrespect, but I don't think this would warrant deletion of the question. Would you? If not, why not write a comment? That would probably result in an email alert, while I doubt a flag would show up.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots 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!

Translated by