Two functions with the same name?

33 次查看(过去 30 天)
So I downloaded the MAAT library which has a function named "fitsread", but after I went to the documentation of the MATLAB package itself, I noticed that another function called "fitsread" which does a similar thing is also installed. How can I make sure to use the one from the MAAT library? I obviously can't just uninstall the MATLAB product because it will delete everything (I think). In other words, how can someone make sure that they are using a function from a very specific package/library?

回答(2 个)

Walter Roberson
Walter Roberson 2022-6-3
use pathtool to move the desired one earlier in the path.
This has the potential to cause problems if something needs the matlab version.
The more general answer is that if you "import" a package then that has high priority. Unfortunately the scope of import is only the immediate function.

VINAYAK LUHA
VINAYAK LUHA 2022-6-3
Q1. How can someone make sure that they are using a function from a very specific package/library
which function_name
Type the above code in MATLAB cmd window ,the paths that appears are the ones which contain your function
the top one is selected by default.
Q2. How can I make sure to use the one from the MAAT library?
Incase you want to call the function from second path in the list ,
  • Remove the first path
  • Call your function
  • Restore the first path
rmpath(first_path);
my_function();
addpath(first path);
Hope this solves your problem.

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by