What are the ways to sum matrix elements in MATLAB?

前端 未结 6 2058
天涯浪人
天涯浪人 2021-02-08 01:26

Given the matrix:

A = [1 2 3; 4 5 6; 7 8 9];
  1. How could you use a for loop to compute the sum of the elements in the matrix?
  2. Writ
6条回答
  •  鱼传尺愫
    2021-02-08 01:59

    You are trying to sum up all the elements of 2-D Array

    In Matlab use

    Array_Sum = sum(sum(Array_Name));

提交回复
热议问题