Matlab - MATLAB Y HUFFMAN Y UITABLE

 
Vista:
Imágen de perfil de DIEGO

MATLAB Y HUFFMAN Y UITABLE

Publicado por DIEGO (19 intervenciones) el 13/05/2013 06:13:25
Hola nuevamente;

hace un par de días pedi ayuda para poder resolver un progrma que realice la codificación de huffman, el asunto es que ya he ehcho lo que me han indicado y perfecto, pero aun tengo un problema más, mi código es este:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
function varargout = huffman(varargin)
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Importamos los datos de una .txt
a=importdata(uigetfile({'*.txt'}, 'Escoger Archivo .txt'));
set(handles.listbox1,'string',a);
handles.a=a;
guidata(hObject,handles);
 
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox1
 
 
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
 
% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
 
 
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Llamada a la cadena de datos
x=handles.a;
j=char(x);
ari=sscanf(j,'%c');
 
% Busca la cantidad de letras del código ascii
 
for j=32:255
    dato=char(j);
    eventos=length(strfind(ari,dato));
    probabilidad=eventos/length(ari);
    if eventos~=0
       a=probabilidad;
       b=dato;
    end
end
 
a=[];
b=[];
c=[];
for i=32:255
n=char(i);
y=strfind(ari,n);
q=length(y);
p1=q/length(ari);
if q==0
m=n;
else
m=n;
p=q;
a=[a m];
b=[b p1];
c=[c p];
end
end
 
%letras
a1=(a(:)');
aa=[a1];
Alfabeto=(aa(:));

%probabilidad
b1=(b(:)');
bb=[b1];
Probabilidad=(bb(:));
 
%cantidad
c1=(c(:)');
cc=[c1];
Cantidad=(cc(:));

%huffman
symbols = (Alfabeto(:)');
sym=double(symbols);
prob = Probabilidad;
[dict,avglen] = huffmandict(sym,prob);
 
% escribir diccionario
temp = dict;
for i = 1:length(temp)
    temp{i,2} = num2str(temp{i,2});
end
temp;
 
prob=temp;
prob(:,1)=[]
Huffman=(prob(:)')

% Presenta los valores en una tabla
rnames = {Alfabeto};
set(handles.uitable3,'RowName',rnames)
set(handles.uitable3,'Data',[Cantidad Probabilidad Huffman])

%Error
d=sum(Probabilidad);
if d==1
    
else
errordlg('Ha ingresado un texto con caracteres no programados',' Entropía ');
end




lo que esta en negrita es basicamente lo que codifica huffman pero necesito mostrar el valos de Huffman en una columna del uitable3, pero no puedo, cuando ejecuto me sale este error pero no se como solucionarlo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Error using set
Data within a cell array must have size [1 1]
 
Error in huffman_01>pushbutton2_Callback (line 190)
set(handles.uitable3,'Data',[Cantidad Probabilidad
Huffman])
 
Error in gui_mainfcn (line 96)
        feval(varargin{:});
 
Error in huffman_01 (line 42)
    gui_mainfcn(gui_State, varargin{:});
 
Error in
@(hObject,eventdata)huffman_01('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
 
 
Error while evaluating uicontrol Callback



entiendo que tiene que ver con que no se puede mostrar el vector Huffman en la uitable, pero se que si se puede lo que pasa es que no se como hacerlo. por favor ayudarme quien pueda.

muchas gracias de antemano
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder