can a new function be defined in the middle of livescript?

5 visualizzazioni (ultimi 30 giorni)
Can one define a function in the middle of LiveScript or does it have to be at the end of the script?

Risposta accettata

Fangjun Jiang
Fangjun Jiang il 26 Mag 2020
Modificato: Fangjun Jiang il 26 Mag 2020
No.
%%
a=1;
function out=timestwo(in)
out=in*2;
end
b=timestwo(a)
Error: File: Untitled Line: 8 Column: 1
Function definitions in a script must appear at the end of the file.
Move all statements after the "timestwo" function definition to before the first local function
definition.

Più risposte (0)

Prodotti


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by