필터 지우기
필터 지우기

How to trace the effect of a change in one function in a program on another function in the same program?

조회 수: 1 (최근 30일)
The general structure of my program is a fairly simple one:
main program
function1(x,y,z);
function2(x1,y1,z1);
functionN(xN,yN,zN);
main program ends
Now if I change something in function1 code, how can I trace the effect of that change in the other functions that get affected.
Thanks.
  댓글 수: 3
Walter Roberson
Walter Roberson 2011년 2월 24일
For example, are you using global variables? Sharing data through some mechanism? Or is the structure actually different than that shown, with some of the routines having outputs that become inputs to other routines?
Peeyush
Peeyush 2011년 2월 28일
I think I should have been more clear in stating my question. I will try to explain again.
I have a program that calls 10 different functions. Now these 10 functions share some of the input arguments i.e. Some input variables are global and are called by two or more different functions.
Now I find I have made a mistake in the forumla in the code of one function (say function FX). So I open and change the formula in the code for that function (function FX). The output I am getting from this function is now being used by another function(s) in the main program. Is there a way to find which other variables/functions (which are dependent on the output of function FX) get affected when I make a change in function FX?

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

채택된 답변

Walter Roberson
Walter Roberson 2011년 2월 28일
No, computing theory indicates that given the Matlab instruction set, it is not possible to analyze with certainty which variables are or are not affected by a change to another variable.
In practice, substituting something like {} in place of a numeric value will likely catch the next place the value is referenced. By inserting such assignments at strategic places one can systematically trace blocks of code affected by a variable.
Usually, though, it is much easier to use the editor's string search to look for instances of the variable name; if necessary, split the editor pane so you can compare argument lists of a function call to that of the called function so that you know the name given to the variable in the new routine.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by