Soustraction between all line of a matrix
2 ビュー (過去 30 日間)
古いコメントを表示
Jonathan Demmer
2020 年 9 月 15 日
コメント済み: Jonathan Demmer
2020 年 9 月 15 日
Hello all,
I have a matrix (6964,1) i would like to do a mathemetical operation between each line of the matrix. i mean line 1 with all the line then line 2 with all the line then line 3 with all the line etc. and I would like that the result return into a new matrix. Can someone help mep lease?
0 件のコメント
採用された回答
BOB MATHEW SYJI
2020 年 9 月 15 日
I hope this helps. If not, please rectify. S is your vector. A is a 6964*6964 matrix which returns the difference between other elements of the vector on corresponding columns
A=zeros(length(S));
for i=1:length(S)
for n=(i+1):length(S)
A(n,i)=S(i)-S(n);
end
end
その他の回答 (1 件)
madhan ravi
2020 年 9 月 15 日
bsxfun(@minus, matrix(:), matrix(:).') % for newer versions bsxfun() is not needed
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!