I need an example of a defined function in M-files
古いコメントを表示
Help me on how to define functions
2 件のコメント
Jan
2012 年 10 月 4 日
Such questions are explained exhaustively in the "Getting Started" chapters of the documentation. Reading this is obligatory, when you want to use such a powerful tool as Matlab.
Habib Bipembi
2012 年 10 月 5 日
回答 (2 件)
Walter Roberson
2012 年 10 月 4 日
Put the following into a file named example.m :
function example
disp('You rang?')
end
Then, invoke it by typing
example
at the command prompt.
It is important that the file name be a .m file that has the same name as the first "function" being defined in the file.
Matt Fig
2012 年 10 月 4 日
- From the command line, type this: edit
- Copy the code below.
- Paste it into the blank window that opened from step 1.
- Save the file, use the name MATLAB gives it.
- From the command line, type this: mysquare(2)
function y = mysquare(x)
% mysquare(x) squares the input argument.
y = x.^2;
カテゴリ
ヘルプ センター および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!