editing a string using GUI editable text/popup within guide

7 ビュー (過去 30 日間)
avram alter
avram alter 2019 年 12 月 5 日
コメント済み: avram alter 2019 年 12 月 11 日
I have a string, where I use strrep to replace a variable witha user input:
string = ('Today, I ate some (x)')
user_input = input('Enter your food: ', 's');
newstring = strrep('string', '(x)', user_input);
I want to use an editable textbox to get user_input. How would I do that?
My full script will have 3 editable textboxes, and 2 popups.
the popups will be changing a directory path, like I do here with sprintf:
user_input_food = input('enter food: ');
user_input_amount = input('enter amount: ');
root = 'C:\Users\Administrator';
% full path should look like C:\Users\Administrator\food\amount\food_amount.txt
filepath = fullfile(root, sprintf('food%s', user_input_food,), user_input_amount, sprintf('food%s_amount%s.txt', user_input_food, user_input_amount);
how do I get a popup menu to populate the user_input_experiment/user_input_squad variables?
  2 件のコメント
Walter Roberson
Walter Roberson 2019 年 12 月 5 日
GUIDE or APp Designer ?
avram alter
avram alter 2019 年 12 月 5 日
using guide, good point

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 12 月 5 日
user_input_food = handles.food_textbox.String; %assuming you named the edit uicontrol food_textbox
user_input_amount = handles.amount_textbox.String;
filepath = fullfile(root, sprintf('food%s', user_input_food), user_input_amount, sprintf('food%s_amount%s.txt', user_input_food, user_input_amount));
how do I get a popup menu to populate the user_input_experiment/user_input_squad variables?
If it is to be done according to computed content, then set the String property of the popup to a cell array of character vectors, one per line. Access the Value property to determine the index of which was selected. If you want to know the selected text, then for example,
experiment_choices = handles.experiment_popup.String;
user_choice = handles.experiment_popup.Value;
user_input_experiment = experiment_choices{user_choice};
  12 件のコメント
avram alter
avram alter 2019 年 12 月 11 日
That's what I thought you meant. Populating the handles and then only actually running the importdata() at the user's behest. I will definitely try that, and update you. Thanks for the help so far, I really appreciate it.
avram alter
avram alter 2019 年 12 月 11 日
that works perfectly, thanks for the help. If you have time, I posted a new question for a connected project. thanks so much.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by