Two functions with the same name?

23 Ansichten (letzte 30 Tage)
Ali Almakhmari
Ali Almakhmari am 3 Jun. 2022
Beantwortet: VINAYAK LUHA am 3 Jun. 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?

Antworten (2)

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

Kategorien

Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by