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

1 次查看(过去 30 天)
Emre Tutucu
Emre Tutucu 2020-6-5
How ı can write a function and sub function.
Can you give me an example ?

回答(2 个)

David Hill
David Hill 2020-6-6
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 个评论
Emre Tutucu
Emre Tutucu 2020-6-6
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

请先登录,再进行评论。


David Hill
David Hill 2020-6-6
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 个评论
Emre Tutucu
Emre Tutucu 2020-6-6
i did already
Image Analyst
Image Analyst 2020-6-6
Then attach all needed files so we can run them ourselves.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by