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)));

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

질문:

2016년 2월 12일

댓글:

2016년 2월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by