How to return a vector output for a vector input for a custom made function?
조회 수: 2 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!