From: Ryan on
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
From: Sadik on
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.
From: Ryan on
"Sadik " <sadik.hava(a)gmail.com> wrote in message <i0e8it$oed$1(a)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?
From: Sadik on
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.
From: ImageAnalyst on
On Jun 29, 4:15 pm, "Ryan " <ryanhutten2...(a)u.northwestern.edu> wrote:
> 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

--------------------------------------------------------
Ryan:
Have you looked at inputdlg, like this example from its help:

prompt = {'Enter matrix size:','Enter colormap name:'};
dlg_title = 'Input for peaks function';
num_lines = 1;
def = {'20','hsv'};
answer = 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
 | 
Pages: 1
Prev: Frequency/Wavenumber
Next: Time series problem