Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

calling a function from.m file A - the function is in .m file B

4 visualizaciones (últimos 30 días)
kajalschopra
kajalschopra el 27 de Jul. de 2015
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I have a function Fn_A defined in a .m file (say file1.m)
I have another function FN_B defined in a .m file (say file2.m)
I want to call Fn_B from Fn_A. Is it possible?
  1 comentario
Azzi Abdelmalek
Azzi Abdelmalek el 27 de Jul. de 2015
Yes it's possible. Before asking, you could just try it.

Respuestas (1)

Walter Roberson
Walter Roberson el 27 de Jul. de 2015
In order to easily call a function from another file, the function must the the first in the second file and the file must be named for the function. In such a case you just call the function normally.
If the function is not the first one in the second file, then in order for the first file to be able to invoke the function, it first needs to have a function handle to the second function. There is no way to generate that handle from outside the second file: you would have to have the first function in that second file construct the handle and make it available to the first function (such as by returning it, or by saving it in a known location such as by using the handles structure)
It is time for you to think about splitting apart that second file.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by