|
|
Creating user entry form GUI
I am trying to create a GUI that will take 2 or 3 inputs which will be strings. These inputs need to be inserted into a text file (which will be executed using linux). How do I write the code to update the text file with these new inputs?
Thanks
|
|
0
|
|
|
|
Reply
|
Ryan
|
6/29/2010 8:15:30 PM |
|
Hi Ryan,
As soon as you say
fid = fopen('yourFile.txt','w');
the contents of your file will be deleted. Now you can go ahead and write anything you want using fprintf.
Best.
|
|
0
|
|
|
|
Reply
|
Sadik
|
6/30/2010 2:02:05 AM
|
|
"Sadik " <sadik.hava@gmail.com> wrote in message <i0e8it$oed$1@fred.mathworks.com>...
> Hi Ryan,
>
> As soon as you say
>
> fid = fopen('yourFile.txt','w');
>
> the contents of your file will be deleted. Now you can go ahead and write anything you want using fprintf.
>
> Best.
Thanks. Is there a way that I can just create a few variables in the txt file that will be updated based on the user input? I do not want to delete the entire text file, i just want to replace 3 individual variables that are repeated several times throughout the text file. I know on linux there is a function called "read" which replaces variables in this manner. Are you aware of a similar matlab function?
|
|
0
|
|
|
|
Reply
|
Ryan
|
6/30/2010 3:03:05 PM
|
|
Actually, I am not aware of something like that. What you could do is read the whole file, change any portion of it [e.g. parts concerning those parameters] and then write back into it.
Useful functions:
fopen
fclose
fgetl
fscanf
textscan
fread
fprintf
fwrite
---------
Best.
|
|
0
|
|
|
|
Reply
|
Sadik
|
6/30/2010 3:48:04 PM
|
|
On Jun 29, 4:15=A0pm, "Ryan " <ryanhutten2...@u.northwestern.edu> wrote:
> I am trying to create a GUI that will take 2 or 3 inputs which will be st=
rings. These inputs need to be inserted into a text file (which will be exe=
cuted using linux). How do I write the code to update the text file with th=
ese new inputs?
>
> Thanks
--------------------------------------------------------
Ryan:
Have you looked at inputdlg, like this example from its help:
prompt =3D {'Enter matrix size:','Enter colormap name:'};
dlg_title =3D 'Input for peaks function';
num_lines =3D 1;
def =3D {'20','hsv'};
answer =3D inputdlg(prompt,dlg_title,num_lines,def);
Then you insert them into your text file using standard fread() and
fprintf() statements. There are a variety of ways to do this
depending on exactly what you want to do.
-ImageAnalyst
|
|
0
|
|
|
|
Reply
|
ImageAnalyst
|
6/30/2010 5:16:47 PM
|
|
|
4 Replies
441 Views
(page loaded in 0.087 seconds)
|
|
|
|
|
|
|
|
|