It is posible to write a script with many functions and call these functions?
4 ビュー (過去 30 日間)
古いコメントを表示
German Preciat Gonzalez
2017 年 1 月 23 日
コメント済み: German Preciat Gonzalez
2017 年 1 月 23 日
I have to write a very large script with a lot of functions within the script. Instead of having functions as a separated files and call them (addpath) I want to have everything in one script. For example:
%script to sum and multiply numbers
a=[1 2 3];
sumValues(a)
multiplyValues(a)
function summedValues=sumValues(vector)
summedValues=sum(vector)
function multipliedValues=multiplyValues(vector)
multipliedValues=prod(vector)
so I obtain when I run the script
summedValues =
6
multipliedValues =
6
Thanks!
1 件のコメント
採用された回答
Guillaume
2017 年 1 月 23 日
Note that addpath is unrelated to calling functions. If the separate files are in the same directory as the script, you can call the functions without any addpath.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Function Creation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!