Two functions with the same name?

37 vues (au cours des 30 derniers jours)
Ali Almakhmari
Ali Almakhmari le 3 Juin 2022
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?

Réponses (2)

Walter Roberson
Walter Roberson le 3 Juin 2022
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 le 3 Juin 2022
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.

Catégories

En savoir plus sur Introduction to Installation and Licensing dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by