Effacer les filtres
Effacer les filtres

How do I pass information from a text box in the GUI to a variable in the .m file?

4 vues (au cours des 30 derniers jours)
How do I pass information from a text box in the GUI to a variable in the .m file? Precisely speaking, I want to put music notes such as A,B,C,C#,D in the text box in the GUI. Once I do this I want these music notes to appear in a variable called song=[] in the .m file.

Réponse acceptée

Walter Roberson
Walter Roberson le 10 Avr 2018
notestr = get(handles.textbox1, 'String');
note_struct = regexp(notestr, '(?<note>[ABCDEFG]#?)', 'names');
note_list = {note_struct.note};
Now note_list will be a cell array of character vectors, each one of A, B, C, D, E, F, G, or one of those followed by #. Commas and spaces and other characters are permitted in the input -- though the above would need touching up to be able to ignore spaces between a note and its following # .
  16 commentaires
Walter Roberson
Walter Roberson le 15 Avr 2018
Modifié(e) : Walter Roberson le 15 Avr 2018
Don't call songmaker again. You only need to call songmaker to build the sound vector.
songmaker should not construct the audioplayer object. The play callback should test to see if there is a valid audioplayer already and if not then construct it. Then it should start playing. The other callbacks should still test that the audioplayer is still valid but should not be constructing the audioplayer, should only be using the one out of the play callback.
MAX
MAX le 15 Avr 2018
You are so good at Matlab programming.
Thanks once again

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Timing and presenting 2D and 3D stimuli dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by