Apply function to each column of matrix for all columns without for loop
조회 수: 37 (최근 30일)
이전 댓글 표시
Hi all,
I have a function "Func(X)" which operations on n-by-1 single column matrix "X" and outputs a scalar quantity. I also have a n-by-m matrix "A" that I would like to apply "Func" for all m columns in "A" and obtain 1-by-m matrix, say B, as a result without using for loop or any iterative definitions. What is the best way to proceed with this?
댓글 수: 4
채택된 답변
추가 답변 (1개)
Greg Heath
2018년 9월 7일
편집: Greg Heath
2018년 9월 7일
The MATLAB CONVENTION is that functions operate on matrix columns.
Therefore, it is only with user-defined functions that operations on rows occur.
Hope this helps.
Thank you for formally accepting my answer
Greg
댓글 수: 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!