I want to create a function function ExtremePoints = AnalyseData( ScanData ).
I want to be able to run the function without passing the argument ScanData, and in this situation I want to use a variable with the same name from Matlab Workspace.
Is this possible, to use inside the body of the function the variable ScanData which appear in workspace?
Or should I first save the content of the variable ScanData from workspace into a .mat file and then load that file in the body of the function?
It is possible, perhaps not entirely recommended. Here’s how:
This pulls the value of
ScanDatafrom thebaseworkspace if no input arguments are supplied (nargin == 0).Use of
evalandevalinis generally discouraged as it makes your code harder to understand and re-use.