Skip to content

Commit

Permalink
Adding octave example
Browse files Browse the repository at this point in the history
  • Loading branch information
giuliadei committed Jan 29, 2025
1 parent 7e5a416 commit bc007e6
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions octave/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/.DS_Store
12 changes: 12 additions & 0 deletions octave/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM matpower/octave:latest@sha256:5d1683c81873c56a37774bc7c42ef3d78a7e107781e974a1b8957073bac4436a

ARG OCTAVE_VERSION="9.2.0"
ARG OCTAVE_IMAGE_REVISION="1"

RUN mkdir /safe_data /safe_outputs /scratch /test

WORKDIR /test

COPY --chmod=0755 src/* .

CMD ["/bin/bash", "run_octave.sh"]
11 changes: 11 additions & 0 deletions octave/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# TRE Octave example

## Running

Run with standard `ces-run` command.

## Notes

In this example, a bash script uses an octave script to generate a plot and then saves the `.png` output to `/safe_outputs`. Both files are found under the `src` directory, which is copied inside the container in the `Dockerfile`.

This example is not interactive.
31 changes: 31 additions & 0 deletions octave/src/plot_example.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
% declaring variable var_x
var_x = [0:0.01:1];

% declaring variable var_y1
var_y1 = sin(4 * pi * var_x);

% declaring variable var_y2
var_y2 = cos(3 * pi * var_x);

% plot var_x with var_y1
plot(var_x, var_y1);

% hold the above plot or figure
hold on;

% plot var with var_y2 with red color
plot(var_x, var_y2, 'r');

% adding label to the x-axis
xlabel('time');

% adding label to the y-axis
ylabel('value');

% adding title for the plot
title('my first plot');

% add legends for these 2 curves
legend('sin', 'cos');

print -dpng 'plot.png'
5 changes: 5 additions & 0 deletions octave/src/run_octave.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

octave plot_example.m

mv *.png /safe_outputs

0 comments on commit bc007e6

Please sign in to comment.