How to return a vector output for a vector input for a custom made function?

1 回表示 (過去 30 日間)
Avishek  Mondal
Avishek Mondal 2017 年 12 月 31 日
編集済み: John D'Errico 2017 年 12 月 31 日
Hi, I know from experience that some Matlab functions like cos will also return a vector if it's input is a vector, i.e. cos(vector) is a vector. Is it possible to do the same with a custom function I've written myself? I am asking this because I want to avoid writing for loops because in Matlab for loops take a long time to execute.

採用された回答

John D'Errico
John D'Errico 2017 年 12 月 31 日
編集済み: John D'Errico 2017 年 12 月 31 日
Of course you can.
function y = myfun(x)
y = x;
end
This returns the vector y, given input vector x. WTP?

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by