You can calculate the average using for loop in Matlab as follows:
main.m221 chars17 lines
The output will be 6
. However, Matlab provides a built-in function mean
to calculate the average of a vector, which is a more efficient and quicker way to do this task.
gistlibby LogSnag