Obtain information on a matrix
Show older comments
Answers (1)
Star Strider
on 22 Apr 2018
For the first, use the size function:
[rows, cols] = size(A);
For the second, create a vector from the matrix elements, then take the mean value of the vector:
Amean = mean(A(:));
Functions such as mean operate on columns, and then on vector elements, so it would otherwise be necessary to calculate ‘mean(mean(A))’. Creating a vector first is much more efficient.
Categories
Find more on MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!