フィルターのクリア

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

4 ビュー (過去 30 日間)
MAX
MAX 2018 年 4 月 10 日
コメント済み: MAX 2018 年 4 月 15 日
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.
MAX
MAX 2018 年 4 月 15 日
You are so good at Matlab programming.
Thanks once again

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTiming 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