How can I create it?

4 visualizzazioni (ultimi 30 giorni)
Taner Cokyasar
Taner Cokyasar il 12 Feb 2016
Commentato: Star Strider il 12 Feb 2016
How can I create a 5x5 matrix with the following criterion: aij = 2cos(0.4(i-j)π)

Risposta accettata

Star Strider
Star Strider il 12 Feb 2016
A bit more efficiently, using meshgrid:
[i,j] = meshgrid(1:5);
a = 2*cos(0.4*(i-j)*pi);
  2 Commenti
Taner Cokyasar
Taner Cokyasar il 12 Feb 2016
Thank you very much. It works out great!
Star Strider
Star Strider il 12 Feb 2016
My pleasure!
The meshgrid function can make a number of matrix calculations easier.

Accedi per commentare.

Più risposte (1)

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

Categorie

Scopri di più su Data Distribution Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by