generating a matrix question
Ältere Kommentare anzeigen
i want to generate a matrix that each element is the sum of its row and column ive tried usin the henkel command but it didnt work is there an alternative or more simple solution thx
Akzeptierte Antwort
Weitere Antworten (1)
Andrei Bobrov
am 11 Dez. 2013
Bearbeitet: Andrei Bobrov
am 11 Dez. 2013
s = [3 4];% let s - size new matrices
A = hankel(2:s(1)+1,s(1)+1:sum(s));
or
A = bsxfun(@plus,(1:s(1))',1:s(2));
or
s = [3 4];
[ii,jj] = ndgrid(1:s(1),1:s(2));
A = ii + jj;
1 Kommentar
mohamed
am 12 Dez. 2013
Kategorien
Mehr zu Matrices and Arrays 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!