RETURN
Simulation
January 2024

Matlab & Simulink on Qarnot Cloud

Matlab is a programming platform designed specifically for engineers and scientists to analyze and design systems and products. The heart of MATLAB is the MATLAB language, a matrix-based language allowing the most natural expression of computational mathematics. It allows matrix manipulations; plotting of functions and data; implementation of algorithms; creation of user interfaces; interfacing with programs written in other languages, including C, C++, Java, and FORTRAN; data analysis; algorithms development; and models and applications creation.

License

This software is proprietary, a license is necessary in order to use it. If you want to test this payload on a real use-case, please get in touch with our team: qlab@qarnot.com.

Versions

The test use case uses Matlab r2023b    
If you are interested in another version, please send us an email at qlab@qarnot.com.

Prerequisites

Before launching the case, please ensure that the following prerequisites have been met.

Test case

This test case simulates the flight of a 0.05 kg rocket. During the first 0.15 s the rocket is propelled up by the rocket engine with a force of 16 N. The rocket then flies up slowing down under the force of gravity. After it reaches the apex, the rocket starts to fall back down. When its down velocity reaches 20 m/s a parachute opens (assumed to open instantly) and the rocket continues to move down at a constant speed of 20 m/s until it hits the ground.

Launching the case

Here is an example of how to run a Matlab use-case on the platform. It assumes that:

To launch the computation on Qarnot, copy this code in a Python script in your working directory. Be sure you have copied your authentication token in the script (instead of <<<MY_SECRET_TOKEN>>>), add the license informations (Your_License_IP, Your_License_Port, Your_Vendor_Port) change the name of the file in FILE_TO_RUN (instead of Your_file_To_Run.m) and execute python3 sample.py in the terminal.

#!/usr/bin/env python3

# Import the Qarnot SDK
import qarnot

conn = qarnot.Connection(client_token='<YOUR TOKEN HERE>')

# Create a task
task = conn.create_task("Example_Matlab_profile", "matlab-simulink", 1)

# Create an input bucket with the case files
input_bucket = conn.create_bucket("matlab-in")
input_bucket.sync_directory('input/')
task.resources.append(input_bucket)

# Create an output bucket
task.results = conn.create_bucket('matlab-out')

# Give parameters regarding the Docker image to be used
task.constants['DOCKER_REPO'] = 'matlab-simulink'
task.constants['DOCKER_TAG'] = 'r2023b'
task.constants['MATLAB_LICENSE_IP'] = 'Your_License_IP'
task.constants['MATLAB_LICENSE_PORT'] = 'Your_License_Port'
task.constants['MATLAB_VENDOR_PORT'] = 'Your_Vendor_Port'
task.constants['FILE_TO_RUN'] = '"Your_File_To_Run.m"' #it's important here to use the double quote

# Submit the task and download results
task.run(output_dir="output")

Results

At any given time, you can monitor the status of your task on the general web interface Tasq. The following figure shows a successful Matlab demo simulation on Tasq. In the red square you can have your output files created by your .m file

In our example the result is the image available in the matlab-out bucket.

Wrapping up

That’s it! If you have any questions, please contact qlab@qarnot.com and we will help you with pleasure!

Return

Our articles