looking for help in indexing of variables

2 ビュー (過去 30 日間)
Ashraf Sherif
Ashraf Sherif 2019 年 2 月 9 日
コメント済み: Ashraf Sherif 2019 年 2 月 10 日
Hi all, I have a matrix C, 3 by 3 it is a random variables with 4 iterations, I want to calculte for each element its instantanous value devided by it's average up to each iteration, the output should be as a matrix M, I did that but with numbering the variables I am looking for a better way to do that, if some one could help will be very thankful.
C =
14.4894 37.8764 6.6557
12.5079 23.9724 22.0415
26.9530 18.5281 19.4084
M =
1 1 1
1 1 1
1 1 1
C =
2.9873 16.6287 11.1656
24.6604 8.9310 10.9217
55.4434 37.2271 7.7009
M =
0.2865 0.4460 1.2911
1.4268 0.4376 0.5727
1.5811 1.4904 0.4835
C =
27.9885 24.7014 16.6055
26.2066 4.5133 4.3492
8.3868 0.7076 23.5264
M =
2.0480 0.8376 1.5458
1.3162 0.2780 0.2758
0.1312 0.0209 1.4968
C =
18.8612 1.7305 7.2938
21.1609 27.3332 18.3864
26.2062 7.6808 8.8939
M =
1.1109 0.0503 0.6400
0.9715 1.8540 1.3399
0.6439 0.3157 0.5003
x1=[];x2=[];x3=[];x4=[];x5=[];x6=[];x6=[];x7=[];x8=[];x9=[];
for i=1:4
F=random('exp',1,3,3);
C=20*log2(1+F)
x1=[x1;F(1)]; x2=[x2;F(4)];x3=[x3;F(7)];x4=[x4;F(2)];x5=[x5;F(5)];x6=[x6;F(8)];x7=[x7;F(3)];x8=[x8;F(6)];x9=[x9;F(9)];
M1=F(1)/mean(x1);M2=F(4)/mean(x2);M3=F(7)/mean(x3);M4=F(2)/mean(x4);M5=F(5)/mean(x5);M6=F(8)/mean(x6);M7=F(3)/mean(x7);M8=F(6)/mean(x8);M9=F(9)/mean(x9);
M=[M1,M2,M3;M4,M5,M6;M7,M8,M9]
end

採用された回答

Matt J
Matt J 2019 年 2 月 9 日
編集済み: Matt J 2019 年 2 月 9 日
F=random('exp',1,3,3,4);
C=20*log2(1+F);
M=C./movmean(C,[4,0],3)
  3 件のコメント
Matt J
Matt J 2019 年 2 月 10 日
編集済み: Matt J 2019 年 2 月 10 日
Upgrade!
Or replace with
M=bsxfun(@times, C./cumsum(C,3) , reshape(1:4,1,1,[]) );
Ashraf Sherif
Ashraf Sherif 2019 年 2 月 10 日
Thank you very much Matt J that is what I want

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by