필터 지우기
필터 지우기

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 (최근 30일)
When I type 'SumNthRowSquares(M,n)' it has an error plz help
  댓글 수: 1
Stephen23
Stephen23 2018년 10월 1일

"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?

댓글을 달려면 로그인하십시오.

답변 (1개)

JohnGalt
JohnGalt 2018년 10월 1일
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

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by