How to go about programming this function in MatLab

1 回表示 (過去 30 日間)
t sizzle
t sizzle 2021 年 4 月 20 日
コメント済み: Rena Berman 2021 年 5 月 6 日
I am trying to program a function into matlab but I am struggling to get started. I want to program it as a function and not as part of a script so that I may use it later on when I need it.
Basicaly, there will be n number of terms, and x and y are arrays that will change in size depending on how have set them up.
  2 件のコメント
Stephen23
Stephen23 2021 年 4 月 28 日
編集済み: Stephen23 2021 年 4 月 28 日
Original question retrieved from Google Cache:
I am trying to program a function into matlab but I am struggling to get started. I want to program it as a function and not as part of a script so that I may use it later on when I need it.
Basicaly, there will be n number of terms, and x and y are arrays that will change in size depending on how have set them up.
Rena Berman
Rena Berman 2021 年 5 月 6 日
(Answers Dev) Restored edit

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2021 年 4 月 20 日
c = @(x,y) sum(sqrt((a-x).^2 + (b-y).^2))

Jan
Jan 2021 年 4 月 20 日
function c = YourSum(x, y, a, b)
c = sum(sqrt((a - x).^2 + (b - y).^2));
end

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by