How can I add a column vector to every column within a cell array?
Ältere Kommentare anzeigen
Ok, so I now have a cell array with 1000 m*n matrices which I have fiddled with earlier.
What I now need to do is to each column within each of those m*n matrices, add a column vector 'A'
So, my m*n matrices look like:
1 2 3, 4 5 6, 7 8 9,
my column vector is
1, 2, 1,
so i want my output to be
2 3 4, 6 7 8, 8 9 10,
Again, please keep this nice and simple for me :)
Akzeptierte Antwort
Weitere Antworten (1)
Azzi Abdelmalek
am 16 Aug. 2012
Bearbeitet: Azzi Abdelmalek
am 16 Aug. 2012
A=[1 2 3; 4 5 6; 7 8 9]
b=[1; 2; 1];
[n,m]=size(A);A=A+repmat(b',1,m)
%now for all your 1000 matrix, if they are in a cell array M
for k=1:1000
A=M{k}
% add a previous code
b=[1; 2; 1];
[n,m]=size(A);A=A+repmat(b',1,m)
end
2 Kommentare
Azzi Abdelmalek
am 16 Aug. 2012
Bearbeitet: Azzi Abdelmalek
am 16 Aug. 2012
it's ok, maby you are missing a vector a. can you post error message? or part of your cell array and your vector.
another thing; when you tape T{1} what did you get?
Kategorien
Mehr zu Matrix Indexing finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!