Altair Compose® Challenge #1: Plotting in Compose with different types of axes

RSGarciarivas
RSGarciarivas
Altair Employee
edited August 2023 in Altair HyperWorks

The main scripting language in Compose, OML, features a rich set of plotting commands for creating 2D and 3D plots. In this challenge we will explore some of them as well some nice features for arranging your plots.

When I was new to engineering scripting languages (Compose, Octave, MATLAB, etc.), I often was able to perform all the calculations I had to but had trouble in the last step of the process, I got stuck in displaying the results in a meaningful way. After going over this challenge, you will be ready to plot your data in different ways the next time you have to.

Download the attached script and follow the comments in there to create all plots. As you will see from the script, all plotting tasks should be done using this data:

x = 1:100;

y = x.^2;

z = x' * y / 2;

theta = 0:0.01:2*pi;

rho = cos(theta + 2*theta).*cos(theta);

The challenge is for you to display these vectors in the following types of plots:

  • Conventional linear axes plot
  • Scatter plot
  • Logarithmic axes plots
  • 3D line and surface plots
  • Polar plot

After plotting in individual figures, create two new figures, one which contains all plots with logarithmic axes and another one containing all 3D plots, however you want to arrange them.

Good luck!

Tip: Check out OML functions like figure, grid, plot, scatter, semilogx, semilogy, loglog, plot3, surf, polar and subplot.

Level: Easy

Product Required: Compose 2020 or later version (including Personal Edition)

The solution can be attached in the comment section of this post. The desired output format is a zip file containing the plots created as JPG images. These images can be saved directly from Compose or they can be screenshots.

Edit: The solution to this challenge has been attached as another OML script. Try to solve it on your own before looking at it!

Comments

  • Xiaolei
    Xiaolei
    Altair Employee
    edited July 2023

    Files attached. It's an interesting exercise!

    Thanks. 

    Xiaolei

  • Anonymous
    Anonymous
    Altair Employee
    edited July 2023

    Really good start for Altair compose learners :)

  • Gabriel Pistorello
    Gabriel Pistorello Altair Community Member
    edited July 2023

    Nice exercise!

  • RSGarciarivas
    RSGarciarivas
    Altair Employee
    edited July 2023

    Files attached. It's an interesting exercise!

    Thanks. 

    Xiaolei

    Nice work!

  • RSGarciarivas
    RSGarciarivas
    Altair Employee
    edited July 2023
    Anonymous said:

    Really good start for Altair compose learners :)

    Hi Ronak. The polar plot and the figure with logarithmic axes subplots look perfect but you are missing all individual plots apart from the polar one. Also, try plotting a single line with plot3. You can do this by indexing z in any way you want.

  • RSGarciarivas
    RSGarciarivas
    Altair Employee
    edited July 2023

    Nice exercise!

    Perfect! Just remember the grid has to be set individually for each figure.

  • Soodong Park
    Soodong Park Altair Community Member
    edited July 2023

    I can't upload the file due to company's policy. so I write the code below instead.

    plot(x,y);
    scatter(x,y);
    semilogx(x,y);
    semilogy(x,y);
    loglog(x,y);
    plot3(x,y,z(:,1,1));
    surf(x,y,z);
    polar(theta, rho);

    subplot(3,1,1); 
    semilogx(x,y);
    subplot(3,1,2); 
    semilogy(x,y);
    subplot(3,1,3); 
    loglog(x,y);

    subplot(2,1,1); 
    plot3(x,y,z(:,1,1));
    subplot(2,1,2); 
    surf(x,y,z);

  • RSGarciarivas
    RSGarciarivas
    Altair Employee
    edited July 2023

    I can't upload the file due to company's policy. so I write the code below instead.

    plot(x,y);
    scatter(x,y);
    semilogx(x,y);
    semilogy(x,y);
    loglog(x,y);
    plot3(x,y,z(:,1,1));
    surf(x,y,z);
    polar(theta, rho);

    subplot(3,1,1); 
    semilogx(x,y);
    subplot(3,1,2); 
    semilogy(x,y);
    subplot(3,1,3); 
    loglog(x,y);

    subplot(2,1,1); 
    plot3(x,y,z(:,1,1));
    subplot(2,1,2); 
    surf(x,y,z);

    hi Soodong. Plot commands look good but each one should be created in a new figure. Also, remember to set a grid for each plot.

  • Kunal Pandit_21294
    Kunal Pandit_21294
    Altair Employee
    edited July 2023

    Interesting exercise! Good for beginners..

    Regards,

    Kunal P

    Please Find Attached.

  • RSGarciarivas
    RSGarciarivas
    Altair Employee
    edited July 2023

    Interesting exercise! Good for beginners..

    Regards,

    Kunal P

    Please Find Attached.

    Perfect!

  • Enrique San Juan
    Enrique San Juan New Altair Community Member
    edited July 2023

    Thank you, Rafael! It was really useful!

  • RSGarciarivas
    RSGarciarivas
    Altair Employee
    edited July 2023

    Thank you, Rafael! It was really useful!

    Good job! I see you also included legends, axis labels and titles. Well done.