필터 지우기
필터 지우기

Function that returns an NxN matrix

조회 수: 3 (최근 30일)
Michael
Michael 2014년 10월 8일
댓글: Andrei Bobrov 2014년 10월 10일
I need to create a function that when a value for N is entered it returns an NxN identity matrix. But this needs to be done without employing Matlab commands which operate on entire matrices, rows, and columns.
  댓글 수: 2
Andrei Bobrov
Andrei Bobrov 2014년 10월 8일
in MATLAB without employing Matlab commands - how?
Stephen23
Stephen23 2014년 10월 8일
All functions require MATLAB commands, starting with the function function.

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

채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 10월 8일
for jj = N:-1:1
out(jj,jj) = 1;
end
  댓글 수: 5
Stephen23
Stephen23 2014년 10월 9일
편집: Stephen23 2014년 10월 9일
Andrei Bobrov: I like the array preallocation through the reversed sequence. That is a nice touch!
Andrei Bobrov
Andrei Bobrov 2014년 10월 10일
Hi Stephen! This is idea by Jan Simon.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by