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

2 次查看(过去 30 天)
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 个评论
Rik
Rik 2019-6-18
@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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by