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

 采纳的回答

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

2 个评论

Thank you very much. It works out great!
My pleasure!
The meshgrid function can make a number of matrix calculations easier.

请先登录,再进行评论。

更多回答(1 个)

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

类别

帮助中心File Exchange 中查找有关 Data Distribution Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by