Borrar filtros
Borrar filtros

matlab command similar to EQU directive

1 visualización (últimos 30 días)
Ganesh
Ganesh el 12 de Ag. de 2011
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 12 de Ag. de 2011
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...

Más respuestas (0)

Categorías

Más información sobre Downloads en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by