How to represent a curve with straight line segments?

13 vues (au cours des 30 derniers jours)
I'm trying to plot the curve segment on the left with line segments only, as the figure in the right. I know there's a function to plot lines but in this problem I need to overlap the lines, with given length, onto the curve and i don't know the coordinates because i'm working with sin and cos curves

Réponse acceptée

Sam Chak
Sam Chak le 3 Juil 2022
Modifié(e) : Sam Chak le 3 Juil 2022
Hi @Luis Eduardo Pacheco González
Just wondering if you want to display a smooth sinusoidal curve like this?
Or, if you are asking for a mathematical solution for computing each line segment that can be used to construct the curve?
subplot(2,1,1)
x = linspace(0, 2*pi, 361);
y = sin(x);
plot(x, y, 'linewidth', 1.5)
grid on, ylim([-1.5 1.5])
subplot(2,1,2)
x = linspace(0, 2*pi, 360/45+1);
y = sin(x);
plot(x, y, 'linewidth', 1.5)
grid on, ylim([-1.5 1.5])
  1 commentaire
Luis Eduardo Pacheco González
Thank you very much, the second plot is the way I wanted to represent a curve. Now I’ll just apply it to my code I'm working on.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by