Prev: Frequency/Wavenumber
Next: Time series problem
From: Ryan on 29 Jun 2010 16:15 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 29 Jun 2010 22:02 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 30 Jun 2010 11:03 "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 30 Jun 2010 11:48 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 30 Jun 2010 13:16 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 |