Apply function to each column of matrix for all columns without for loop
108 次查看(过去 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!