How can I use a a text file as a source for your popup menu in guide (i.e. items in the list)

I am trying to make a database system to store information into specified profiles. I have been successful in setting up the structure for the profiles, but however the number of profiles keep on updating per usage. I have managed to to write a .m file to write all names of profiles into a .txt file. I simply need a solution upon how I can link this .txt file to my drop down menu in guide.

2 commentaires

Jan
Jan le 22 Avr 2014
Modifié(e) : Jan le 22 Avr 2014
Why do you write the names to a txt file at first? Is this indirection useful? Does the list change its contents during the GUI is open? What did you try already and which problems are you working on?
They are profiles created and stored in a struct file. Because the popupmenu only accepts strings, the best solution I could find was to write it all into a text file using fopen/fclose and link the popup menu to the text file. {Therefore anytime the m. file is opened, the text file is rewritten.}. Kindly assist me if there is a better way...Thanks

Connectez-vous pour commenter.

 Réponse acceptée

however you have the popup menu updated, read in the text file with each entry as a cell(M profiles in one column). Then you can update the popup menu with
set(handles.popupmenu1,'String',profileNamesReadfromTXT)

2 commentaires

run Text_Writer_Oil A = importdata('popup_menu_oil.txt'); set(hObject,'String',A);
That is the code and is now working perfectly (popup menu)
The text writer code is as shown below (this is the part that does the writing)
fid = fopen('popup_menu_oil.txt','w'); for s = 1: sum(a.id(:,1)~=0) if new.field_name{s,1} ~= '''' c = new.field_name{s,1}; fprintf(fid,'%s\n',c); end end fclose(fid);
I had to do a little sorting before finally writing the above stated
However I still want to ask, is there a better way to do this?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by