|
From: | Rik |
Subject: | Re: Functions in scripts |
Date: | Tue, 24 Jan 2017 11:52:15 -0800 |
On 01/24/2017 11:17 AM, Nicholas
Jankowski wrote:
Thanks. So Matlab is reading through the entire script once and accepting forward declarations. There should be a way to accomplish the same thing in Octave because Octave already knows how to do this for function files and forward declarations of subfunctions. The following function in a file script3.m does that %%%%%%%%%%%%% function script3 () x = 1; localfunctions () z = f(x) end function y = f(x) y = 2 * x; end %%%%%%%%%%%%% And running it produces %%%%%%%%%%%% ans = { [1,1] = @f } z = 2 %%%%%%%%%%%% Mike's questions still remains. After running the original script, what does which f return? If it is empty then the function is localized to the script. --Rik |
[Prev in Thread] | Current Thread | [Next in Thread] |