필터 지우기
필터 지우기

It is posible to write a script with many functions and call these functions?

조회 수: 1 (최근 30일)
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!

채택된 답변

Guillaume
Guillaume 2017년 1월 23일
As of R2016b, you can have local functions in scripts.
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 CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by