About sub function............

How ı can write a function and sub function.
Can you give me an example ?

Respuestas (2)

David Hill
David Hill el 6 de Jun. de 2020

0 votos

function out=showMe(in)
n=1;
out=executeSub();
function o=executeSub()%I assume you are talking about a nested function
o=5*n;
end
end
Look at matlab help: Nested Functions

1 comentario

Emre Tutucu
Emre Tutucu el 6 de Jun. de 2020
thanks but im trying this code its didnt work. what is wrong?
clc;
clear;
function Soru6
aci=input('Lütfen açıyı giriniz : ');
F=input('Lütfen kuvveti giriniz : ');
mesnet
function mesnet
y=aci*F
fprintf('%g',y);
end
end

Iniciar sesión para comentar.

David Hill
David Hill el 6 de Jun. de 2020

0 votos

function Soru6
aci=input('Lütfen açıyı giriniz : ');
F=input('Lütfen kuvveti giriniz : ');
mesnet
function mesnet
y=aci*F
fprintf('%g',y);
end
end
Works just fine but you still need to execute it.
Soru6;

4 comentarios

Emre Tutucu
Emre Tutucu el 6 de Jun. de 2020
yes i do it but doesnt work
Error code ;
(Function definitions are not permitted in this context.)
madhan ravi
madhan ravi el 6 de Jun. de 2020
You need to save it as a separate file in the name Soru6.m
Emre Tutucu
Emre Tutucu el 6 de Jun. de 2020
i did already
Image Analyst
Image Analyst el 6 de Jun. de 2020
Then attach all needed files so we can run them ourselves.

Iniciar sesión para comentar.

Categorías

Más información sobre Get Started with MATLAB en Centro de ayuda y File Exchange.

Preguntada:

el 5 de Jun. de 2020

Comentada:

el 6 de Jun. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by