필터 지우기
필터 지우기

matlab command similar to EQU directive

조회 수: 1 (최근 30일)
Ganesh
Ganesh 2011년 8월 12일
I have written a large program (almost 1500 lines). Now I need to change the parameters of one function which has been written in very initial part of the code. For example: say f(x,y) to f(x,y,z) Is there something like EQU directive which is used in many of assembly languages of microcontrollers? Please help. Thanks in advance.

채택된 답변

Walter Roberson
Walter Roberson 2011년 8월 12일
No there is not.
Is there a default value that can reasonably be applied for z (perhaps calculated by x and y) ? If there is, then you can code
function f(x,y,z)
if ~exists('z','var')
z = ... %the default value
end
If this makes sense then you can make the changeover gradually, first doing the places were a different z is important, and then for consistency going back and filling in the ones were it is less important.
In the case where you know the name the variable would have in the calling code, you could use something like
function f(x,y,z)
if ~exists('z','var')
try
z = evalin('caller','z');
catch
z = ... %some default
end
end
I do not really comment this, but if it gets you through a crunch and you are sure you will be able to clean up the code afterwards... Note that if you just "intend" to clean up the code afterwards that chances are the code will stay warped, as there are always more things to do...

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by