Take the 2-minute tour ×

I'm really new to matlab programming and I can't figure something out. I spent hours googling and no luck. I'm trying to make an app that will take a text file convert it to binary and then convert the binaries to hamming code. That's the first part the rest isn't important for this question.

The GUI is printing out my output in a column, and I want it to print it out in a row. The variable is printed out in a row normally, but in the GUI it's printed out in a column...

The program takes the text from the txt file converts every character to a binary digit and the I make cells for each characters digit which are then put into a function that does the hamming encoding. So the output is a cell array.

This is the main part of the program:

[filename pathname] = uigetfile({'*.txt'}, 'File Selector');
fullpathname = strcat(pathname, filename);
text = fileread(fullpathname);             
set(handles.text1, 'String', fullpathname) 
binarno = dec2bin(text, 8);                 

L = length(text);   

C = num2cell(binarno,2)

D = cellfun(@enkoder, C,'uniformoutput', 0)

set(handles.text2, 'String', D)

I tried a lot of stuff, and nothing worked. I don't know why it prints out the cell arrays D in a column.. instead of a row. If I try D{1} I normally get a row of the hamming code.

And this part of the enkoder function:

function hamm = enkoder(ulaz)

%the hamming encoding part of the code goes here

hamm = [prva_pozicija, druga_pozicija, jedan, cetvrta_pozicija, 
dva, tri, cetiri, osma_pozicija ,pet, sest, sedam, osam] 
%this is the output from the code

So I guess the questions is how do I print out a cell array in rows in a GUI label ?

share|improve this question
uicontrol('style','text','String',{'111','22','333'}','Units','Normalized','Pos‌​ition',[0 0 1 1]) seems to work. Your problem is probably related to D. Can you try to do class(D) and tell us the result? –  Andrey Jun 26 '13 at 22:23
I don't quite know where to put this uicontrol that you wrote. And the class of D is cell –  Filkatron Jun 26 '13 at 22:35
ok, I figured it out gonna edit my answer –  Filkatron Jun 26 '13 at 22:50

1 Answer 1

up vote 0 down vote accepted

Using [D{:}] instead of D in last line may help.

edit: use num2str(cell2mat(D)) instead

share|improve this answer
Nope, it still prints out a column :S –  Filkatron Jun 26 '13 at 22:23
can you show how D looks like? –  Mohsen Nosratinia Jun 26 '13 at 22:26
This is how it looks like in the console, and in the gui. snag.gy/rFg1g.jpg The two hamm in the console, that's what I want in the gui.. –  Filkatron Jun 26 '13 at 22:29
use num2str(cell2mat(D)) instead –  Mohsen Nosratinia Jun 26 '13 at 22:51
Yeah thanks I figured it out just now lol Gonna accept your answer though :) –  Filkatron Jun 26 '13 at 22:53

Your Answer


