Making a vector with letters

8 Ansichten (letzte 30 Tage)
S.ANIL Ercetin
S.ANIL Ercetin am 21 Dez. 2017
Kommentiert: S.ANIL Ercetin am 21 Dez. 2017
hi everyone,
these codes work correctly with numbers but i change the numbers with letters it does not work.
if i write [1 2 3 4 5 6] in alphabet there is no problem. it works.
I need run this codes with letters
when I run it with latters the codes which name is "randsrs" give me a error.
error="Dimensions of matrices being concatenated are not consistent."
How can i fix this problem. What should i write instead of "randsrsc" codes?
i have to change {'a' 'b' 'c'} to [ a a b a c a b c a b]
please help me
alphabet = ['a' 'b' 'c' 'd' 'e' 'f']
p = [.5 .125 .125 .125 .0625 .0625]
dict = huffmandict(alphabet,p)
sig = randsrc(1,10,[alphabet; p])
comp = huffmanenco(sig,dict)
dsig = huffmandeco(comp,dict)
  1 Kommentar
Stephen23
Stephen23 am 21 Dez. 2017
Bearbeitet: Stephen23 am 21 Dez. 2017
@S.ANIL Ercetin: Note that in MATLAB [] are a concatenation operator, and are not a list operator as in some other languages (MATLAB does not have a list operator). This means that this:
alphabet = ['a' 'b' 'c' 'd' 'e' 'f']
is actually equivalent to this:
alphabet = 'abcdef'
and could be defined more generally using:
alphabet = 'a':'f'

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 21 Dez. 2017
alphabet = ['a' 'b' 'c' 'd' 'e' 'f'];
p = [.5 .125 .125 .125 .0625 .0625];
dict = huffmandict(num2cell(alphabet), p);
sig = char( randsrc(1,10,[double(alphabet); p]) );
comp = huffmanenco(sig,dict)
dsig = cell2mat(huffmandeco(comp,dict))
  1 Kommentar
S.ANIL Ercetin
S.ANIL Ercetin am 21 Dez. 2017
it exactly works, thanks for your help.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Large Files and Big Data finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by