How do write a function within the same main code

15 visualizaciones (últimos 30 días)
Watheq Elias
Watheq Elias el 8 de Abr. de 2011
Hello everybody,
I want to know if it is possible to write a function within the same main code rather than write it in separate M file.
Thanks in advance for any help.

Respuesta aceptada

Matt Fig
Matt Fig el 8 de Abr. de 2011
Put all of this into one M-file. Then call it like this: get_sub(5)
function [OUT] = get_sub(A)
OUT = subfun(A); % Call the subfunction.
function [OUT_SUB] = subfun(B)
OUT_SUB = B.^2;

Más respuestas (1)

Paulo Silva
Paulo Silva el 8 de Abr. de 2011
yes with subfunctions

Categorías

Más información sobre Holidays / Seasons 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