Since this matrix has some pattern to it, must be a nicer way to write it? Thanks

1 commentaire

dpb
dpb le 1 Mai 2016
Modifié(e) : dpb le 1 Mai 2016
Edit it to align it so it's clearly legible what the pattern is--too hard to keep columns straight as is, sorry...but using diag and friends may be of some help.

Connectez-vous pour commenter.

 Réponse acceptée

Roger Stafford
Roger Stafford le 1 Mai 2016
Modifié(e) : Roger Stafford le 1 Mai 2016

0 votes

k = 1e6*(diag(s(1:22),1)+diag(s(1:22),-1)+...
diag(-[s(1:22),0]-[0,s(1:22)]));
I am assuming s is a row vector here. Make the obvious change if it is a column vector.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB 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