How to stop a parabola from intersecting itself?

1 view (last 30 days)
I need to graph multiple parabolas on one plot, but when I plot the entire parabola (symmetric across the y-axis) it intersects itself.
clc;clear;close;
RPM_v = [0.1,0.2,0.3,0.4,0.5];
R = .05;
h0 = .15;
%define constants and change units
omega_v = RPM_v.*2*pi/60; %[rad/s]
g = 9.807; %[m/s^2]
r = linspace(0,R); %[m]
phi = linspace(0,2*pi); %[rad]
r_R = r./R;
%PLOT
%2D figure
Fig_2 = figure('Name','Graphical Display with Ratio Measurements',...
'Units','normalized','Position',[.005,.005,.4,.5]);
Axes_2 = axes('Parent', Fig_2,'NextPlot', 'add');
z_v = 1;
n = 1;
while length(z_v) ~= 6
%equation of surface
z_z0 = (h0 - omega_v(n)^2/(2*g)*(R^2/2 - r.^2))/h0 %[m]
xlabel('r/R');
ylabel('z/z0');
title('RPM on a Height vs. Radius Graph');
plot(Axes_2,[-r_R,r_R],[z_z0,z_z0]);
z_v(n+1) = 1;
n = n+1;
end
RPM_num = {'RPM = 0.1','RPM = 0.2','RPM = 0.3','RPM = 0.4',...
'RPM = 0.5'};
legend(Axes_2,RPM_num);
When I just use
plot(Axes_2,r_R,z_z0);
it doesn't graph both sides of the graph. I do not know how to modify this so it displays like a normal parabola.

Accepted Answer

Jan
Jan on 2 Mar 2018
Edited: Jan on 2 Mar 2018
Replace:
plot(Axes_2,[-r_R,r_R],[z_z0,z_z0]);
by:
x = [-(r_R(end:-1:2), r_R];
y = [z_z0(end:-1:2), z_z0];
plot(Axes_2, x, y);
Your original x values are e.g. (simplified:)
r_R = [0, 1, 2]
z_z0 = [0, 1, 4]
Then you have plotted:
plot([-0,-1,-2,0,1,2], [0,1,4,0,1,4])
and this draws the unwanted line. My suggestion creates:
plot([-2,-1,0,1,2], [4,1,0,1,4])

More Answers (0)

Categories

Find more on Discrete Data 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!