Two functions with the same name?

37 visualizaciones (últimos 30 días)
Ali Almakhmari
Ali Almakhmari el 3 de Jun. de 2022
Respondida: VINAYAK LUHA el 3 de Jun. de 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?

Respuestas (2)

Walter Roberson
Walter Roberson el 3 de Jun. de 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 el 3 de Jun. de 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.

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by