Apply function to each column of matrix for all columns without for loop
Show older comments
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 Comments
madhan ravi
on 6 Sep 2018
upload your code and datas
Jeongseop Lee
on 6 Sep 2018
Paolo
on 6 Sep 2018
If B is the output matrix, what do you want B to be for that A?
Jeongseop Lee
on 6 Sep 2018
Edited: Jeongseop Lee
on 6 Sep 2018
Accepted Answer
More Answers (1)
Greg Heath
on 7 Sep 2018
Edited: Greg Heath
on 7 Sep 2018
1 vote
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
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!