Effacer les filtres
Effacer les filtres

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 vue (au cours des 30 derniers jours)
function [s] = multiSum(A)
s=sum(A(:,end))
end

Réponse acceptée

Walter Roberson
Walter Roberson le 16 Fév 2023
You can extract diagonals by using diag . And I see you already found sum . Be sure to read about the dim parameter of sum
  2 commentaires
the cyclist
the cyclist le 16 Fév 2023
I'm not convinced they "found" sum, as opposed to being given this function framework to adapt for a homework assignment. :-)
Joshua
Joshua le 16 Fév 2023
for this homework I was given NO function framework to adapt. But thank you for the guide, I will update accordingly.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by