How to stop a parabola from intersecting itself?

조회 수: 1 (최근 30일)
Jasmine Alvarez
Jasmine Alvarez 2018년 3월 2일
편집: Jan 2018년 3월 2일
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.

채택된 답변

Jan
Jan 2018년 3월 2일
편집: Jan 2018년 3월 2일
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])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by