f



How to save text files in Matlab GUI from edit text box

Dear all,
please help me in understanding the usage of GUI. I found on the web a suggested way to write a button callback to read the content of an edit text box and save to a txt file, that is:

%save text of command.txt file
fid = fopen('command.txt','wt');
fprintf(fid,'%c',get(handles.edit1,'String'))
fclose(fid);

Anyway, the text in the box is saved in the text file in a wrong and very peculiar way; if I write in the box something like:

PALA
POLO

I find in the command.txt file has been saved the following:

PPAOLLAO

and I can't manage to obtain more than one line. Any help or suggestion is welcome, thanks!
0
Matteo
6/4/2014 10:00:17 AM
comp.soft-sys.matlab 211266 articles. 22 followers. lunamoonmoon (257) is leader. Post Follow

1 Replies
1028 Views

Similar Articles

[PageSpeed] 14

"Matteo Lorenzini" <matteo.lorenzini@roma2.infn.it> wrote in message 
news:lmmqnh$muc$1@newscl01ah.mathworks.com...
> Dear all,
> please help me in understanding the usage of GUI. I found on the web a 
> suggested way to write a button callback to read the content of an edit 
> text box and save to a txt file, that is:
>
> %save text of command.txt file
> fid = fopen('command.txt','wt');
> fprintf(fid,'%c',get(handles.edit1,'String'))
> fclose(fid);
>
> Anyway, the text in the box is saved in the text file in a wrong and very 
> peculiar way; if I write in the box something like:
>
> PALA
> POLO
>
> I find in the command.txt file has been saved the following:
>
> PPAOLLAO

That's correct. MATLAB is column major, and so when FPRINTF iterates through 
the character matrix:

['PALA'; 'POLO']

the first element is 'P' and the second element is also 'P'. The third 
element is the first 'A' in the first line. The ordering of elements is:

reshape(1:8, [2 4])

There are a couple different ways to handle this depending on your level of 
experience with MATLAB. You could write each row at a time, or you could use 
a cell array of strings instead of a character matrix.

-- 
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on 
http://www.mathworks.com 

0
Steven
6/4/2014 2:31:31 PM
Reply:

Similar Artilces:

Copy text from edit text box on MATLAB GUI to specific cell on an excel file
Good day! I would like to copy or transfer the text from an edit box on MATLAB GUI (via push button) to a specific cell on an excel file. Can you suggest on how to accomplish this one or even cite sample codes? If this is not possible, can you suggest anything on how to allow the user to input texts using the MATLAB GUI (via push button) and automatically transfer the texts to a specific cell on excel? It is preferable to have the texts copied/stored to the excel file without opening the actual excel file. Thank you so much. "Mary Requilman" <maryrose.requilman@gmail....

Save Text from GUI Edit Text Box
Hi there! I'm very new to MatLab, this is probably very easy to do - please, if you can, give me very explicit instructions. I'm creating a GUI in GUIDE that has a editable text box. I want a button that, when clicked, will write that text to a text file (in this case, directory.txt). If there is a way to browse for a directory and input the directory into the text box in the GUI, that would be way awesome, but it's not a priority. Thanks very much everybody! "Kyle " <kylebshr@gmail.com> wrote in message <jucb5d$s0b$1@newscl01ah.mathworks.com>... ...

Viewing text files in GUI Edit Text boxes
Hi, I am importing a text file containing numeric and character or just numeric data (of unknown size) and I want to view the contents in a GUI Edit Text box. I've thus far managed to format a string of the numeric only file and view it: datastr=sprintf('%-12.3f',handles.rawdata); set(handles.fdesc,'Visible','on','String',datastr) But, say the file is 20x20 will display the first four numbers of each column then move to the next line and display the next 4, etc. Is there anyway to: a) Add breaks in the data to show the user that the next set of data is f...

Viewing text files in GUI Edit Text boxes #2
Hi, I am importing a text file containing numeric and character or just numeric data (of unknown size) and I want to view the contents in a GUI Edit Text box. I've thus far managed to format a string of the numeric only file and view it: datastr=sprintf('%-12.3f',handles.rawdata); set(handles.fdesc,'Visible','on','String',datastr) But, say the file is 20x20 will display the first four numbers of each column then move to the next line and display the next 4, etc. Is there anyway to: a) Add breaks in the data to show the user that the next set of data is f...

Matlab GUI: displaying a vector in an edit text box
I'm writing a GUI that serves to write data to a robot. The robot takes vectors of 11 elements. Once the user puts his vector in the edit text box, I check lenght and correct the vector if necessary. The problem is that when I try to set my edit text to display a vector, the whole box just vanishes. My code is: input = eval(get(hObject,'String')); n=numel(input); if n~=11 if n>11 %avertissement %première ligne de l'avertissement msgboxText{1} = 'Le vecteur est trop long'; %deuxième ligne de l'aver...

Reading a text file into a Matlab Matrix
Hello there, I have a text file that contains the following; word11 word12 word13 word14 word21 word22 word23 word24 word31 word32 word33 word34 I want to read it into a 3x4 matrix (each word in a separate cell) I tried to use; data = textread('fileName.txt', '%s', 'delimiter', '\n') - puts each line in one cell data = textread('fileName.txt', '%s', 'delimiter', ' ') - puts each word in one cell but in a 12x1 matrix/array [col1 col2 col3 col4] = textread('tE.txt', '%s %s %s %s', 'delimit...

inserting certain text from text file to matlab
i am using a software which outputs me a text file with 1000 lines of data. I specifically need certain lines (lets say line 100- 150), and input them into matlab. These lines actually consists of columns (lets say "X-Axis" "Y-Axis" "Z-Axis"). The first line does include the title of these columns. I want matlab to read these lines, and then using a code...generate some graphs for me. Any help would be appreciated. Anuj Anuj wrote: > i am using a software which outputs me a text file with 1000 lines of > data. I specifically need certain lines (lets say ...

MATLAB GUI-edit text
How to write command in MATLAB GUI so,whenever the user enter value OR number in my EDIT TEXT and after they enter the PUSH BUTTON,the action will automatically plotting my AXES. Says I have a transfer function. TF= (-0.0911+1.554z^-1)/(-1.036z^-1-1+0.036372z^-2) Thanks in advance. "EMELLINE HOLT JANG" wrote in message <ki8u8r$nmc$1@newscl01ah.mathworks.com>... > How to write command in MATLAB GUI so,whenever the user enter value OR number in my EDIT TEXT and after they enter the PUSH BUTTON,the action will automatically plotting my AXES. Says I have a transfer fun...

editing a text file with matlab
I am trying to open up text file with matlab and change 3 values from a vector. For instance wi have a text file and i want to go to the 10th line of the text and edit 3 values <0,1,0>, <.5147,-1.6694,-.1925> in this case i want to have as variable the .5 the -1.6 -.19. As enter the new values iwant to save this edit text file as a new text file. thanks, V. > I am trying to open up text file with matlab and change 3 values > from > a vector. > For instance wi have a text file and i want to go to the 10th line > of > the text and edit 3 values <0,1,0>, > ...

Updating Edit text in MATLAB GUI
Hi, I have a question regarding updating the values in the edit text components of a MATLAB GUI. I have a 'for' loop which does computation on an array of images. I want the image's index which is being processed in the edit text box. So, in each iteration of the loop I do the computation and update the edit text box using: set ( handles.edit2, 'String' , [ 'Processing image number: ', num2str (i) ] ) ; The problem is, the text is not getting updated after each loop, but instead it gets updated at the end after all the iterations are finished. do I need to ad...

Reading text file in a gui in matlab
Hi friends, i need a help.i need to read an assembly program wriiten in a text file(notepad) into matlab as a whole.i tried fgets n fgetl.but only 1 line is shown in static or edit text at a time.how can i display the whole text at a time? also can i show line by line by incorporatinf looping function?means can i know the sequencing of instructions even if there is a loop function? plz reply soon.thanks in advance. On 3/10/2013 12:36 AM, Harith M wrote: > Hi friends, > i need a help.i need to read an assembly program wriiten in a text > file(notepad) into matlab as a whole...

edit a text file within matlab ?
Hello all, I was wondering if I could load a text file into matlab, and then edit it all automatically. Basically, I want to load a text file and then find and replace certain values which I have loaded from seperate data. such as finding the word NAME and replacing it with a number I have previously loaded into matlab. Is this acheivable easily? On 8/1/2011 11:52 PM, mahdi wrote: > Hello all, I was wondering if I could load a text file into matlab, and > then edit it all automatically. > Basically, I want to load a text file and then find and replace certain > values which ...

edit text in matlab GUI 7
i'm working on a GUI which can calculate Ohm's Law by inputing any 2 figures of the 3 data in the formula, V=IR. however i was stucked at the m-file editor.. how can i write the command so that any 2 values (for example, current and voltage) inputed in the edit text.. will produce the result (for example, resistance) in the third edit text box after pressing a particular button? i have read through a lot of documents... still have no idea how to start.. thanks in advance.. In article <fciknq$ic$1@fred.mathworks.com>, c ws <theorekz@gmail.com> wrote: >i'm working ...

text output box in MATLAB GUI?
I want to create a MATLAB GUI with GUIDE and I want one of the components to be a text output box containing many lines of text (wrapped, if possible) that has been generated by the program. As the program proceeds this text is continuously rewritten as the program operates on it and changes it. The user never needs to input text into this box. Is this possible? How do I do it? Thanks. John MAc John Macdonald wrote: > > > I want to create a MATLAB GUI with GUIDE and I want one of the > components to be a text output box containing many lines of text > (wrapped, if possible) tha...

Web resources about - How to save text files in Matlab GUI from edit text box - comp.soft-sys.matlab

Undocumented Matlab
Undocumented, unsupported and hidden features in Matlab

MATLAB - Wikipedia, the free encyclopedia
MATLAB ( mat rix lab oratory) is a numerical computing environment and fourth-generation programming language . Developed by MathWorks , MATLAB ...

Open Directory - Science: Math: Software: MATLAB
about dmoz - help Top : Science : Math : Software : MATLAB Submit here webpages that explain and illustrate how to use MATLAB. Sites that cover ...

The Smart Emergency Response System Using MATLAB and Simulink - YouTube
In the aftermath of an earthquake, every second counts for disaster victims. Imagine a system that can locate people quickly and help first responders ...

The A-Z of Programming Languages: MATLAB
What prompted the development of MATLAB?

Matlab: Invalid .NET Framework. Either the specified framework was not found or is not currently supported ...
If you are trying to compile Matlab into .Net framework, you might encounter this message, even though you have the .Net framework installed ...

Matlab edges closer to electronic design automation world
Matlab, one of the world's most widely used products for algorithmic development, has long occupied its own niche far removed from EDA and hardware ...

Can I/How do I use DMTCP with a parallel pool of MATLAB workers? · Issue #223 · dmtcp/dmtcp · GitHub
dmtcp - DMTCP: Distributed MultiThreaded CheckPointing matlab -nodisplay -r "parpool('local',4); parfor i=1:10, pause(1); fprintf('%i ',i); end; ...

Using MATLAB and SDR to Reverse Engineer 433MHz Messages
... so he focused on studying the methodology and the tools available for analyzing 433MHz RF transmission. He describes the process of using MATLAB ...

Matlab 6.5
After several years' absence, Matlab 6.5, comes back to the Mac. This is exceptionally good news for science and engineering labs with a code ...

Resources last updated: 1/26/2016 9:14:58 PM