Connecting various matlab code files.

Hi,
If I have a bunch of files in matlab and want one of the files to call some other file, how do I do so. Do I need to put all the files in the same folder. For example I have 1.m and 2.m and in 1.m I would like to use a function of 2.m(or something related to that) how do I go about it.
Thanks in advance

답변 (1개)

Matt J
Matt J 2012년 10월 4일

0 개 추천

You can put the files in different folders, but both folders need to be on the MATLAB path. See ADDPATH, PATHTOOL, and other related functions for ways to modify your path.

댓글 수: 2

mmomudnet momo
mmomudnet momo 2012년 10월 4일
Thanks Matt, I will ensure to add all paths. How will I call a function of 2.m while I am running 1.m, do I simply call the function or do I have to pass some reference to 2.m.
Matt Kindig
Matt Kindig 2012년 10월 4일
If 2.m and 1.m are both on the path, you can simply call the function 2.m while running 1.m-- no references are necessary.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Search Path에 대해 자세히 알아보기

질문:

2012년 10월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by