Can two 201x1 arrays be added in matrix multiplication way to produce a 201x201 matrix?

I'm having trouble creating a for loop nested in a for loop that allows me to add to single column arrays in a matrix multiplicative way. In other words take two 201x1 arrays add them in the way described below to produce a 201x201 matrix. Please help if you can.
And what I mean by a matrix multiplicative way is :.
A=[1
2
3
4]
B=[A
B
C
D]
A+B=[1+A 2+A 3+A ]
1+B 2+B 3+B
1+C 2+C 3+C
1+D 2+D 3+D....

 Réponse acceptée

Take a look at bsxfun:
C = bsxfun(@plus, A, B')

2 commentaires

(but switch transpose from B to A to match result in the order posted)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by