I have a function that takes an N X M array, A, and I want to take the sum of each column. The sum of the rows and sums of the two diagonals, the major diagonal first.

1 次查看(过去 30 天)
function [s] = multiSum(A)
s=sum(A(:,end))
end

采纳的回答

Walter Roberson
Walter Roberson 2023-2-16
You can extract diagonals by using diag . And I see you already found sum . Be sure to read about the dim parameter of sum

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by