🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

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

User: "RSGarciarivas"
Altair Employee
Updated by RSGarciarivas

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

Sort by:
1 - 12 of 121
    User: "Xiaolei"
    Altair Employee
    Updated by Xiaolei

    Files attached. It's an interesting exercise!

    Thanks. 

    Xiaolei

    User: "Anonymous"
    Altair Employee
    Updated by Anonymous

    Really good start for Altair compose learners :)

    User: "Gabriel Pistorello"
    Altair Community Member
    Updated by Gabriel Pistorello

    Nice exercise!

    User: "RSGarciarivas"
    Altair Employee
    OP
    Updated by RSGarciarivas

    Files attached. It's an interesting exercise!

    Thanks. 

    Xiaolei

    Nice work!

    User: "RSGarciarivas"
    Altair Employee
    OP
    Updated by RSGarciarivas

    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.

    User: "RSGarciarivas"
    Altair Employee
    OP
    Updated by RSGarciarivas

    Nice exercise!

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

    User: "Soodong Park"
    Altair Community Member
    Updated by Soodong Park

    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);

    User: "RSGarciarivas"
    Altair Employee
    OP
    Updated by RSGarciarivas

    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.

    User: "Kunal Pandit_21294"
    Altair Employee
    Updated by Kunal Pandit_21294

    Interesting exercise! Good for beginners..

    Regards,

    Kunal P

    Please Find Attached.

    User: "RSGarciarivas"
    Altair Employee
    OP
    Updated by RSGarciarivas

    Interesting exercise! Good for beginners..

    Regards,

    Kunal P

    Please Find Attached.

    Perfect!

    User: "Enrique San Juan"
    Altair Community Member
    Updated by Enrique San Juan

    Thank you, Rafael! It was really useful!

    User: "RSGarciarivas"
    Altair Employee
    OP
    Updated by RSGarciarivas

    Thank you, Rafael! It was really useful!

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