How can I create a 5x5 matrix with the following criterion: aij = 2cos(0.4(i-j)π)

 採用された回答

Star Strider
Star Strider 2016 年 2 月 12 日

0 投票

A bit more efficiently, using meshgrid:
[i,j] = meshgrid(1:5);
a = 2*cos(0.4*(i-j)*pi);

2 件のコメント

Taner Cokyasar
Taner Cokyasar 2016 年 2 月 12 日
Thank you very much. It works out great!
Star Strider
Star Strider 2016 年 2 月 12 日
My pleasure!
The meshgrid function can make a number of matrix calculations easier.

サインインしてコメントする。

その他の回答 (1 件)

jgg
jgg 2016 年 2 月 12 日

0 投票

Try this
A = 2*cos(0.4.*pi.*(repmat([1:5]',1,5) - repmat([1:5],5,1)));

1 件のコメント

Taner Cokyasar
Taner Cokyasar 2016 年 2 月 12 日
Thank you jgg.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by