Two functions with the same name?

조회 수: 40 (최근 30일)
Ali Almakhmari
Ali Almakhmari 2022년 6월 3일
답변: VINAYAK LUHA 2022년 6월 3일
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