필터 지우기
필터 지우기

editing a string using GUI editable text/popup within guide

조회 수: 3 (최근 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?

채택된 답변

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 CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by