日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab缩小矩阵尺寸,Matlab中对矩阵使用矩阵尺寸的索引

發布時間:2025/3/21 循环神经网络 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab缩小矩阵尺寸,Matlab中对矩阵使用矩阵尺寸的索引 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

轉自stackoverflow: Addressing Matlab matrix with Index-matrix

涉及bsxfun的使用。Addressing Matlab matrix with Index-matrix

I am using the command [A,idx] = sort(A), which sorts the matrix A columnwise, which is what I want. The idx matrix shows how each column of A has been sorted. Now if I try and access B(idx) MATLAB assumes I am referencing B in an absolute manner. This is however not what I want, I want the columns of B sorted with the same scheme A was sorted with.

I am therefore looking for a command that will index a matrix columnwise. Of course I can easily do this with a loop, but it seems like a pretty poor solution. I have also come up with this solution, but it’s not very pretty

idx = idx+repmat(0:size(idx,1):size(idx,2)*size(idx,1)-1,size(idx,1),1)

Thanks in advance.

Consider the following:

A = randi([1 10],[5 4]);

[AA,idx] = sort(A);

Your solution is not bad, you could improve it a bit by replacing the REPMAT call with BSXFUN:

idx = bsxfun(@plus, idx, 0:size(idx,1):numel(idx)-1);

isequal(AA,A(idx))

Another alternative is to convert to linear indices using SUB2IND:

idx = sub2ind(size(idx), idx, repmat(1:size(idx,2),size(idx,1),1));

isequal(AA,A(idx))

總結

以上是生活随笔為你收集整理的matlab缩小矩阵尺寸,Matlab中对矩阵使用矩阵尺寸的索引的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。