Call overloaded function from specific toolbox in MATLAB -


i have matlab-toolboxes installed. in matlab version 1 of toolbox-functions collides another. in case hessian. want use hessian function of symbolic-toolbox.

when in c/c++ functions multiple defined function cos , still want use “standard” cos-function can write:

std::cos(x);

is there similar in matlab?

in similar way describing c/c++, can use specific toolbox function adding name of toolbox first : toolboxname\function2call()

first use which command make sure of function toolbox loaded specific call syntax.

since not have toolbox mentioning i'll use classic fopen function example.

the first fopen function called without other parameter built in function used return handle file. indeed, which command confirms that:

>> fopen built-in (c:\tlab13a\toolbox\matlab\iofun\fopen) 

now let's want use fopen function open serial port, need prefix call fopen name of toolbox/object, so: serial\fopen. let's first make sure way of calling point right function:

>> serial\fopen c:\tlab13a\toolbox\matlab\iofun\@serial\fopen.m  % serial method 

bingo !

and make sure works when calling these functions, let's call them real (with dummy parameters):

>> fopen('toto') ans =     -1  >> serial\fopen('toto') error using serial (line 72) port must specified. 

it worked. first simple call fopen('toto') return -1 because couldn't find file named "toto".
second call serial\fopen('toto') errored because serial port not defined, right function called.


edit: can override order in matlab fetch functions re-ordering matlab path. if put symbolic toolbox before other 1 in path, when called without explicit information, matlab execute first function finds in path.

i still recommend first solution explicit declaration though, because changing path order mess other function call in case have many overloaded functions.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

How do you convert a timestamp into a datetime in python with the correct timezone? -