資源簡介
蟻群算法粗糙集matlab代碼,實測可用

代碼片段和文件信息
function?h?=?condentropy(xy)
if?~(isvector(x)?&&?isvector(y))????%xy?must?be?one-dimensional?vectors
????disp(‘Error:?input?data?must?be?one?dimensional?vectors‘)
????h?=?nan;
elseif?size(x)~=size(y)?%vectors?must?have?the?same?size
????disp(‘Error:?input?vectors?must?have?the?same?size‘)
????h?=?nan;
else
????valuesX?=?unique(x);????%different?values?found?in?vector?x
????valuesY?=?unique(y);????%different?values?found?in?vector?y
????
????numValues?=?numel(x);???%number?of?elements?contained?on?each?vector
????h?=?0;??%initial?value?of?conditional?entropy
????
????for?i?=?valuesX‘??%for?each?different?value?found?in?x
????????
????????iOcurrences?=?find(x==i);???%ocurrences?in?x?being?i
????????numOcurrences?=?numel(iOcurrences);?%number?of?ocurrences?in?x?being?i
????????pi?=?numOcurrences?/?numValues;??%probability?p(i)
????????
????????for?j?=?valuesY‘???%for?each?different?value?found?in?y
????????????jOcurrences?=?numel(find(y(iOcurrences)==j));???%ocurrences?in?subset?of?y?being?j
????????????if?jOcurrences?>?0??%if?there?where?at?at?least?one?ocurrence
????????????????pjcondi?=?jOcurrences?/?numOcurrences;??%partial?conditional?entropy?for?specific?values?of?x?and?y
????????????????h?=?h?-?pi*pjcondi*log10(pjcondi);???%cumulative?of?partial?conditional?entropies
????????????end
????????end?
????end
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3951??2014-05-03?17:37??main.m
?????文件????????774??2014-05-02?16:25??pos.m
?????文件????????246??2014-05-02?06:13??weight.m
?????文件???????1366??2014-05-02?16:13??condentropy.m
?????文件????????245??2014-05-02?01:46??DistinguishMatrix.m
?????文件?????????93??2014-05-02?16:13??gama.m
?????文件????????317??2014-05-02?03:04??GetCore.m
?????文件????????901??2014-05-01?22:52??ind.m
-----------?---------??----------?-----??----
?????????????????7893????????????????????8
- 上一篇:均值濾波和中值濾波matlab代碼
- 下一篇:XFEM的程序
評論
共有 條評論