简体   繁体   English

将Matlab直方图值应用于Matlab中的矩阵

[英]Applying matlab histogram values to matrix in matlab

This might be simple and I apologize if it is so. 这可能很简单,如果是这样,我深表歉意。

In matlab I have a double precision matrix which can theoretically have the range of +/- infinity. 在matlab中,我有一个双精度矩阵,理论上可以在+/-无穷大范围内。

I would to use the histogram function in matlab to change the values of the matrix. 我会在Matlab中使用直方图函数来更改矩阵的值。

For instance, if data elements fall within histogram bin 1 then I would like to assign the value of 1 to this and all of its instances. 例如,如果数据元素落在直方图bin 1内,那么我想为该值及其所有实例分配值1。

Is there a quick and cheap way of doing this? 有没有一种快速而便宜的方法来做到这一点?

I have tried lookuptables etc but matlabs LUT is a pain. 我已经尝试过lookuptables等,但是matlabs LUT是一种痛苦。

Thank you for looking at my question 谢谢你看我的问题

I think I just cracked it ... 我想我刚刚破解了...

Make a new function out of hist and after edges in the m file add this line: 在hist中创建一个新函数,并在m文件的边缘之后添加以下行:

[~,my_labels] = histc(y,edges,1);

and my_labels will contain your matrix with the histogram values instead of the actual values. 和my_labels将包含具有直方图值而不是实际值的矩阵。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM