Filter löschen
Filter löschen

Write a function SumNthRowSquares(M,n) that returns the sum of the squares of the numbers in the nth row of matrix M. Use ‘sum’ only to sum a vector. In other words, retrieve the appropriate row and sum it.

1 Ansicht (letzte 30 Tage)
When I type 'SumNthRowSquares(M,n)' it has an error plz help
  1 Kommentar
Stephen23
Stephen23 am 1 Okt. 2018

"When I type 'SumNthRowSquares(M,n)' it has an error"

Have you written a function named SumNthRowSquares, and saved it in a file SumNthRowSquares.m somewhere on the MATLAB Search Path?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

JohnGalt
JohnGalt am 1 Okt. 2018
I presume you want the actual function? if so, save the following to a file.
function out = SumNthRowSquares(M,n)
out = sum(M(n,:).^2));
end

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by