Skip to content

Commit

Permalink
Merge pull request #46 from NAG-DevOps/adding_matlab_script
Browse files Browse the repository at this point in the history
Adding matlab-example
  • Loading branch information
smokhov authored May 2, 2024
2 parents 026522e + eff5b3b commit daacf25
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/matlab-example.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
% Turn on the diary to start logging output to a file
diary('console_output.txt')

% Define the size of the matrices
n = 4;

% Generate two random matrices A and B of size n x n
A = rand(n);
B = rand(n);

% Multiply the two matrices
C = A * B;

% Compute the eigenvalues of the resulting matrix C
eigenvalues = eig(C);

% Optionally, print the matrices and the eigenvalues to the MATLAB console
disp('Matrix A:');
disp(A);
disp('Matrix B:');
disp(B);
disp('Product Matrix C:');
disp(C);
disp('Eigenvalues of Matrix C:');
disp(eigenvalues);

% Turn off the diary to stop logging
diary off
2 changes: 1 addition & 1 deletion src/matlab-slurm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ module list
# -nojvm : Tells Matlab to run without the Java Virtual Machine to reduce overhead
# test.m : Matlab commands file

srun matlab -nodisplay -nodesktop -nojvm < test.m
srun matlab -nodisplay -nodesktop -nojvm < matlab-example.m

0 comments on commit daacf25

Please sign in to comment.