简体   繁体   English

MATLAB列出高于阈值的值

[英]MATLAB List values above threshold

I have a 3D matrix. 我有一个3D矩阵。 I can use the below code to find the number of elements above 1.61. 我可以使用下面的代码来查找1.61以上的元素数量。 How can I actually list the elements that are above 1.61 and show what value they are? 我怎样才能真正列出1.61以上的元素并显示它们的价值? for instance, if I have a value of 8.1 and 9.1, I would like Matlab to tell me those two values. 例如,如果我的值为8.1和9.1,我希望Matlab告诉我这两个值。 Can I do that? 我能这样做吗?

for i = 1:5
     A = ans.atom_data(:,5,i);
     count(i,:) = sum(A(:)>1.61)

end

If you only want to know the values, use logical indexing, like this: 如果您只想知道值,请使用逻辑索引,如下所示:

result = A(A>1.61);

If you want to obtain the result for each third-index-layer of a 3D array B , you can do it with cells: 如果要获取3D阵列B每个第三索引层的结果,可以使用单元格进行:

result = cellfun(@(x) x(x>1.61), squeeze(mat2cell(B,size(B,1),size(B,2),ones(1,size(B,3)))),'uni',0);

Then result{1} gives the values corresponding to B(:,:,1) , etc. 然后result{1}给出对应于B(:,:,1)等的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 矩阵matlab中的阈值 - threshold values in a matrix matlab 使用MATLAB排除图形中确定阈值以上的饱和光谱 - Excluding saturated spectra above a determined threshold in a graph using MATLAB 查找MATLAB中每个单元的阈值以上元素的频率 - Find frequency of elements above a threshold for each cell in MATLAB 如何在Matlab的条形图中将值置于条形上方? - How to put values above bars in barchart in Matlab? 在 matlab 中,如何计算高于阈值水平线的 plot 下的面积? 附图 - In matlab, how to calculate area under the plot above a threshold horizontal line? Fig attached 仅限Matlab代码如果像素值超过给定的阈值,则计算像素数而不是它们的总和 - Matlab Code only Calculating number of pixels and not their sum, if pixel value falls above given Threshold value 在数组中添加值并在Matlab中与循环内的阈值进行比较 - Add values in array and compare with threshold within loop in Matlab 在Matlab中移动窗口中计数数量值超过给定阈值 - count number values exceeds given threshold in moving window in matlab MATLAB:将矩阵中的值相加,直到一列的阈值水平 - MATLAB: summing values in matrix up to a threshold level of one column Matlab-在值超过阈值n次时查找索引 - matlab - find index for when values exceeds a threshold n number of times
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM