Effacer les filtres
Effacer les filtres

how to add matrix ?

2 vues (au cours des 30 derniers jours)
Aniket
Aniket le 13 Mai 2013
I have Aik = 2*2 matrix and i want to add another matrix of 2*2 to Aik matrix ...
for example
w = [100 200]; % frequency vector
m = length(w);
Aik = zeros(2,2,m); % matrix for 2 frequencies
for i = 1:m
Aik(:,:,i) = [0 1; w(i) 0];
end
the above code create Aik matrix of 2*2 for each frequency mentioned in the frequency vector 'w'.
but now i want to add another 2*2 matrix
for example
b = [0 1;0 0]
this b matrix I want to add with Aik for both dimensions
Aik(: ,: , 1)+ b and Aik(: ,: , 2)+ b
how should i do this in the loop ?

Réponses (1)

Honglei Chen
Honglei Chen le 13 Mai 2013
bsxfun(@plus,Aik,b)

Catégories

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