フィルターのクリア

Writing a 3x3 matrix as the 3rd and 4th dimesions of a multidimenstioanl array

2 ビュー (過去 30 日間)
Rodney McCabe
Rodney McCabe 2020 年 5 月 14 日
回答済み: Rik 2020 年 5 月 14 日
I have a function that returns a 3x3 covariance matrix (and a 1x3 mean value vector). I would like to "insert" this as the 3rd and 4th dimensions of a (l , w , 3, 3) array (and a (l, w, 3) array). I can do this with a couple of for loops. I would think that Matlab has a more elegant/efficient way of doing this. Thanks.
Below covRGBa is a 3x3 matrix and aveRGBa is a 1x3 vector
[covRGBa,aveRGBa] = covary(RGB,r,c,xleft,xright,ytop,ybottom,n,perimeter);
for i = 1:3
aveRGB(c,r,i)=aveRGBa(i);
for j = 1:3
covRGB(c,r,i,j)=covRGBa(i,j);
end
end

採用された回答

Rik
Rik 2020 年 5 月 14 日
This should work:
[covRGBa,aveRGBa] = covary(RGB,r,c,xleft,xright,ytop,ybottom,n,perimeter);
aveRGB(c,r,:)=aveRGBa;
covRGB(c,r,:,:)=covRGBa;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by