Effacer les filtres
Effacer les filtres

How to build a new matrix

1 vue (au cours des 30 derniers jours)
Moe
Moe le 29 Oct 2014
Commenté : Titus Edelhofer le 29 Oct 2014
I have a matrix
a = [4;6;8;2;8;2];
And I want it to be like:
b = [7;8;11;12;15;16;3;4;15;16;3;4];
Matrix b is calculated based on following formula:
7 = 4*2-1
8 = 4*2
11 = 6*2-1
12 = 6*2
15 = 8*2-1
16 = 8*2
3 = 2*2-1
4 = 2*2
15 = 8*2-1
16 = 8*2
3 = 2*2-1
4 = 2*2

Réponse acceptée

Mischa Kim
Mischa Kim le 29 Oct 2014
Something like
b = reshape(bsxfun(@minus,2*repmat(a,1,2),[1 0])',1,[])

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by