editing a string using GUI editable text/popup within guide

7 vues (au cours des 30 derniers jours)
avram alter
avram alter le 5 Déc 2019
Commenté : avram alter le 11 Déc 2019
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 commentaires
Walter Roberson
Walter Roberson le 5 Déc 2019
GUIDE or APp Designer ?
avram alter
avram alter le 5 Déc 2019
using guide, good point

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 5 Déc 2019
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 commentaires
avram alter
avram alter le 11 Déc 2019
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 le 11 Déc 2019
that works perfectly, thanks for the help. If you have time, I posted a new question for a connected project. thanks so much.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by