How do I call function with the same name from different toolbox?
33 views (last 30 days)
Show older comments
I am trying to use the "tf" function that takes a digitalFilter object as the input and outputs the numerator and denominator vectors. However the control system toolbox tf function does the opposite.
0 Comments
Answers (2)
Star Strider
on 11 Jun 2020
lpFilt = designfilt('lowpassiir','FilterOrder',8, ...
'PassbandFrequency',35e3,'PassbandRipple',0.2, ...
'SampleRate',200e3); % Example From ‘designfilt’ Documentation
[num,den] = tf(lpFilt); % Transfer Function Polynomials
.
0 Comments
Image Analyst
on 11 Jun 2020
If you do
>> which -all functionName
and it shows several functions in different folders then MATLAB will take the top/first one. To see what functions you have that are overloaded, run my attached utility, what_is_overloaded.m.
If you want to run one that is second or lower on the list, you need to temporarily remove the path of the first one, then call your function, then restore the path of the first one.
rmpath(folder1); % Remove path of first functionName from search path.
% Now it will no longer see the first functionName, unless it's in the current folder.
functionName();
addpath(folder1); % Restore original folder.
I think you could also do it by changing directory to the folder of the one you want to run temporarily:
currentFolder = pwd; % Save original folder
cd(folderWhereFunctionNameLives); % Change to the folder of the functionName that you WANT to run lives.
% Now it will no longer see the first functionName, unless it's in the current folder.
functionName();
cd(currentFolder); % Restore original folder.
8 Comments
Walter Roberson
on 9 Dec 2020
I also recommend using pathtool -- it gives a nice visual interface.
I have another same function in another directory, but it doesn't show up when I do 'which -all functionName'.
Functions in the current diretory always have priority over functions in any other directory when you call them by name. Therefore if you have a function (not a method) by the same name in your current directory, and in another directory, and you want to call the one in the other directory, you cannot do that directly.
What you can do is
curdir = cd('ThatOtherDirectory')
SomeVariableName = @NameOfFunction
cd(curdir);
after which
SomeVariableName(parameter, parameter, parameter...)
will invoke the one from that other directory, not the one from the current directory. Function handles remember the path to the file and use it when the function is called.
Fabrice Lambert
on 2 Oct 2021
Is there any way to toggle the various functions in the help? For example, in my installation when I press F1 on "predict" it opens the Neural Network function. But what if I want to see the help for the linear model predict? Is there a shorter way than having to scroll through all the options in the documentation help?
See Also
Categories
Find more on Install Products in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!