フィルターのクリア

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 Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by