フィルターのクリア

Setting Variable Text Based on Radio Button

2 ビュー (過去 30 日間)
Declan Simons
Declan Simons 2015 年 3 月 27 日
コメント済み: Image Analyst 2015 年 3 月 27 日
I want to have 4 variations of the same format to display 4 sections of predefined text when a radio button is pushed. How would I do this?
  2 件のコメント
Adam
Adam 2015 年 3 月 27 日
Can you elaborate a little? You mean you want 4 radio buttons each with one of your options on? One radio button isn't really a radio button at all. What do you want to format?
Declan Simons
Declan Simons 2015 年 3 月 27 日
Yes there are 4 buttons and for each button a selection of 4 texts that I want to display. So each button will display 4 messages.

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

採用された回答

Image Analyst
Image Analyst 2015 年 3 月 27 日
Try something like this:
masterString = 'abcdefghijklmnopqrstuvwxyz1234567890';
radioButton1Value = get(handles.rad1, 'Value');
radioButton2Value = get(handles.rad2, 'Value');
radioButton3Value = get(handles.rad3, 'Value');
radioButton4Value = get(handles.rad4, 'Value');
if radioButton1Value
index1 = 1; % Whatever....
index2 = 3; % Whatever....
elseif radioButton2Value
index1 = 10; % Whatever....
index2 = 30; % Whatever....
elseif radioButton3Value
index1 = 15; % Whatever....
index2 = 26; % Whatever....
elseif radioButton4Value
index1 = 22; % Whatever....
index2 = 31; % Whatever....
end
substring = masterString(index1:index2);
  2 件のコメント
Declan Simons
Declan Simons 2015 年 3 月 27 日
Not working on it now will hopefully get it working and get you your rightful answer allocation.
Can you just explain this part, as what each component does? As I need 4 strings of multiple words for each button
index1 = 1; % Whatever....
Image Analyst
Image Analyst 2015 年 3 月 27 日
Let's say your string is 100 characters long. Exactly how are you going to tell the program what character to start on and what character to stop at? Somehow you have to tell it a starting and stopping index from which to extract a substring.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by