How to draw a polyline?

NilsWaap
NilsWaap New Altair Community Member
edited October 2020 in Community Q&A

Hello,

I would like to draw a polyline into a figure.

 

I tried to use the function 'polyline' but unfortunately there is no help availabe to this function.

 

I tried this:

polyline('position',[5 5;4 6;4 7;5 8;6 8;7 7; 7 6]);

 

But its not working. A figure is created without axes and polyline. No error messages occours.

 

Regards

 

Nils

Tagged:

Answers

  • robertavarela
    robertavarela New Altair Community Member
    edited August 2019

    Nils,

     

    You are right, the Help is missing for this function and it will come in the next release (v2019.3).

     

    The syntax for it would be:

         data = [5 5;4 6;4 7;5 8;6 8;7 7; 7 6]';
         figure(1);
         h = polyline(1, 'polydata', data);

    Where the first argument is figure handle and the third one is the data set. In your case, the figure will be very small using these inputs:

    image.png.c51fc7b256d9f316994a9e3de1474e85.png

     

    But if you slightly change your data set to data = [5 5;104 106;104 7;5 8;106 8;7 7; 7 106]', for instance, we'd get:

    image.png.38aa90e4802e8d7f8e84a75d30731acf.png

    Regards,

     

    Roberta