External function calling inside another function
16 ビュー (過去 30 日間)
古いコメントを表示
Can an external function created be called inside another function.Please explain with an example. Thanks.
0 件のコメント
採用された回答
その他の回答 (2 件)
sixwwwwww
2013 年 10 月 9 日
Here is a simple example of calling one function within another function:
% Function 1 calling function 2
function output1 = fun1(input1, input2)
value_fun2 = fun2(input1, input2);
output1 = value_fun2 * input1 * input2;
end
% Defining function 2
function output2 = fun2(in1, in2)
output2 = in1 + in2;
end
You can save both function in the same folder then it will work fine
2 件のコメント
Steven Lord
2021 年 7 月 22 日
Then you define it to accept more than 2 inputs and you have fun1 call it with more than 2 inputs. Nothing about this technique limits it to only working with two inputs.
out1 = fun1(2, 3, 4)
% Function 1 calling function 2
function output1 = fun1(input1, input2, input3)
value_fun2 = fun2(input1, input2, input3, 42);
output1 = value_fun2 * input1 * input2;
end
% Defining function 2
function output2 = fun2(in1, in2, in3, in4)
output2 = in1.^in3 + in2.*in4;
end
Adam Wide´n
2021 年 1 月 28 日
Hi!
How can I write a cylinder volume as a external fuction, there radius r , height h are fuction arguments?
best wishes
Adam
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!