hello. how I create function?

2 ビュー (過去 30 日間)
Joseph
Joseph 2023 年 5 月 23 日
コメント済み: Torsten 2023 年 5 月 23 日
on line 179 there is word checkHexagonal.
i want to creat a local function for the checkHexagonal. where is the proper line to creat this function and what are things need to be attached with this function to make this code functionable?

回答 (3 件)

Torsten
Torsten 2023 年 5 月 23 日
編集済み: Torsten 2023 年 5 月 23 日
You should ask the authors of the code why they didn't include the function "checkHexagonal".
Maybe these are the additional functions you search for:
  2 件のコメント
Joseph
Joseph 2023 年 5 月 23 日
how can i include ths function...
Torsten
Torsten 2023 年 5 月 23 日
You should learn about MATLAB in the online tutorial first:

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


Joseph Meyer
Joseph Meyer 2023 年 5 月 23 日
Option 1) Create the function at the bottom of the script, below all other code.
Option 2) Create another file. As long as the file is in the same folder, matlab will detect it.
Either way, the syntax is the same:
function [output1, output2] = checkHexagonal(input)
your_calculation = 1+1;
output1 = your_calculation;
output2 = "blabla";

Walter Roberson
Walter Roberson 2023 年 5 月 23 日
where is the proper line to creat this function
At the end of the current code.
what are things need to be attached with this function to make this code functionable?
The code must have a function keyword. It must define at least one output variable. It must accept at least two input parameters (but it is not required to do anything with them).
The function will have to assign something to the first output variable (unless the first output variable happens to have the same name as one of the input parameters.)
When used at the end of the script, there must be an end keyword matching the function keyword.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by