how to use huffmandict code

2 ビュー (過去 30 日間)
narimen boucenna
narimen boucenna 2020 年 7 月 15 日
コメント済み: narimen boucenna 2020 年 7 月 16 日
i wanted to use this code
huffmandict(symbols,prob)
but the only thing i have is text file with characters , so i need a code that helps me to find symbols and prob using only those characters

回答 (1 件)

Parth Dethaliya
Parth Dethaliya 2020 年 7 月 15 日
clc;clear
Char = char(importdata('***.txt'));%Read characters from .txt file
Total = size(Char,2);
% Here, 2 --> if you have written characters in row.
% Use 1 instead of 2 if ypu have written in column.
Ascii = double(Char);
Unique_Values = unique(Ascii);
Counts = histc(Ascii,Unique_Values);
Probability_array = zeros(1,size(Char,2));
for i = 1: size(Char,2)
Instance = Char(i);
Instance_Ascii_Value = double(Instance);
Instance_Count = Counts(Unique_Values==Instance_Ascii_Value);
Probability_array(i) = Instance_Count/Total;
end
  1 件のコメント
narimen boucenna
narimen boucenna 2020 年 7 月 16 日
so i should be using this Instance_Count/Total for prob ?? and Total for symbols ?

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

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by