Calling specific cells and averaging
2 ビュー (過去 30 日間)
古いコメントを表示
Edward Lannon
2020 年 11 月 16 日
コメント済み: Edward Lannon
2020 年 11 月 16 日
Hello,
I have a 3000X3000 matrix. I also have a list of coordinates that I would like to use to indicate which values to select and average all the selected values. I can't seem to do it. I attached an example of a list.
Thank you for your time.
2 件のコメント
Geoff Hayes
2020 年 11 月 16 日
Edward - please explain how the list of coordinates relates to the 3000x3000 matrix.
採用された回答
Hrishikesh Borate
2020 年 11 月 16 日
Hi,
I understand that you want to calculate average of elements present at indices stored in the file “VisualVisualTest.mat”. This can be done using following code:-
visualTest = load('VisualVisualTest.mat');
a = magic(3000); %3000x3000 matrix
visualCordsall = visualTest.VisualVisualCordsall;
indicesMatrix = transpose(reshape(cell2mat(visualCordsall),2,[]));
sz = [3000, 3000];
ind = sub2ind(sz, indicesMatrix(:,1), indicesMatrix(:,2));
avgValue = mean(a(ind));
Where, avgValue stores the average value.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!