How do I plot an arc or parabola

10 views (last 30 days)
peter obi
peter obi on 19 Nov 2015
Answered: Prateekshya on 29 Aug 2024
I just started learning matlab and I have found plotting an arc and parabola very difficult no matter how hard I read previously posted questions about it. Here is a picture of what I wanna try to plot with the arcs hand drawn using paint. However am gonna use one side as an example (the parabola in red). My start point=[2,10], critical point=[4,9], end point=[5,10]. Thank you

Answers (1)

Prateekshya
Prateekshya on 29 Aug 2024
Hello Peter,
To plot a parabola or arc in MATLAB, you can use the respective mathematical equations to generate data points and then plot them by connecting with each other. The mathematical equation for an arc is and where 'r' is the radius and 'θ' is the angle. Here is a sample code for plotting an arc using this equation:
% Parameters for the arc
radius = 5; % Radius of the circle
theta1 = 0; % Start angle in radians
theta2 = pi/2; % End angle in radians
center = [0, 0]; % Center of the circle (x, y)
% Generate theta values
theta = linspace(theta1, theta2, 100);
% Parametric equations for the arc
x = center(1) + radius * cos(theta);
y = center(2) + radius * sin(theta);
% Plot the arc
figure;
plot(x, y, 'b-', 'LineWidth', 2);
axis equal;
xlabel('X');
ylabel('Y');
title('Circular Arc');
grid on;
You can change the values of angles to change the rotation of the arc. You can use the equation for parabola in a similar way to plot a parabola which is . Take some constant values for 'a', 'b' and 'c' and generate 'x' values using 'linspace'.
I hope this helps you in plotting the required graphs!

Categories

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