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

4 次查看(过去 30 天)
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.

采纳的回答

Walter Roberson
Walter Roberson 2018-4-10
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 个评论
Walter Roberson
Walter Roberson 2018-4-15
编辑:Walter Roberson 2018-4-15
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Timing and presenting 2D and 3D stimuli 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by