Borrar filtros
Borrar filtros

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

4 visualizaciones (últimos 30 días)
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 10 de Abr. de 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 comentarios
Walter Roberson
Walter Roberson el 15 de Abr. de 2018
Editada: Walter Roberson el 15 de Abr. de 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 el 15 de Abr. de 2018
You are so good at Matlab programming.
Thanks once again

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Timing and presenting 2D and 3D stimuli en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by