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

 Réponse acceptée

Star Strider
Star Strider le 12 Fév 2016

0 votes

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

2 commentaires

Taner Cokyasar
Taner Cokyasar le 12 Fév 2016
Thank you very much. It works out great!
Star Strider
Star Strider le 12 Fév 2016
My pleasure!
The meshgrid function can make a number of matrix calculations easier.

Connectez-vous pour commenter.

Plus de réponses (1)

jgg
jgg le 12 Fév 2016

0 votes

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

Catégories

En savoir plus sur Data Distribution Plots dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by