[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Functions in scripts: Matlab evolves
From: |
Julien Bect |
Subject: |
Functions in scripts: Matlab evolves |
Date: |
Tue, 24 Jan 2017 15:56:17 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 |
Hi all,
I just learned that functions definitions are now allowed in Matlab
scripts (>= R2016b).
But the functions definitions must be at the end of the script.
https://fr.mathworks.com/help/matlab/matlab_prog/create-functions-in-files.html
So, the following script works in Octave but fails in Matlab:
%%%%%%%%%%%%%%%%%
x = 1;
function y = f(x)
y = 2 * x;
end
z = f(x)
%%%%%%%%%%%%%%%%%
and this one works in Matlab (>= R016b) but fails in Octave:
%%%%%%%%%%%%%%%%%
x = 1;
z = f(x)
function y = f(x)
y = 2 * x;
end
%%%%%%%%%%%%%%%%%
@++
Julien
- Functions in scripts: Matlab evolves,
Julien Bect <=