App Designer - Button group

Hello, I am working on a GUI using two buttons where the enhancement operations perfromed on an image can be changed. Once I select the required operation; I have an another drop down gives options in relation to the first selection. My questions is
  • It looks like by default the first button is always pressed. So when am running if condition to check whether the first button is selected or not; some how the code within the if not executing; it is only executing when the value is changed (means when option changed from one radio button to the other and vice versa)
How can i access the initial value or default value of radio button selection.
Thanks.

回答 (2 件)

Cris LaPierre
Cris LaPierre 2020 年 9 月 17 日

0 投票

8 件のコメント

Venkata Khambhammettu
Venkata Khambhammettu 2020 年 9 月 17 日
編集済み: Venkata Khambhammettu 2020 年 9 月 17 日
Thanks for your response. I did that before; after that I posted this Qn :). Means i think something else is not correct. Here is my code. Please let me know if you get a chance.
Cris LaPierre
Cris LaPierre 2020 年 9 月 17 日
It would be easier to help if you shared the mlapp file.
Venkata Khambhammettu
Venkata Khambhammettu 2020 年 9 月 17 日
Please see attached. Thanks.
Cris LaPierre
Cris LaPierre 2020 年 9 月 17 日
For you, it looks like the default is to have no button selected. This would cause your if statement to evaluate as false, and therefore the code inside it to not be executed.
if app.LinearStretchingButton.Value
Note that your dropdown is also unselected by default, so those if statements will also not execute.
if strcmp(dropdown_value,'Low') % also check 'Medium' and 'High'
Venkata Khambhammettu
Venkata Khambhammettu 2020 年 9 月 18 日
Thank you Cris.
I think am not following you correct. But, I did modify the code a bit and make it mroe easier to follow (i guess) by deleting repetitive code and putting in a function. This time it is updating the image but only if i selected the second method and then the linear stretching. Since the Linear stretching is selected by default, How can start showing result without moving back and forth. Thank you.
Cris LaPierre
Cris LaPierre 2020 年 9 月 18 日
編集済み: Cris LaPierre 2020 年 9 月 18 日
That was my point. Linear stretching is NOT selected by default. If you look at the screen shot, the radio buttons are both unselected.
Venkata Khambhammettu
Venkata Khambhammettu 2020 年 9 月 18 日
I see what you are saying now. Linear stretching must be selected to even go into the if statement. In the modified code (attached above) ; I do have linear stretching selected and contrast is at Low. For reason, i dont understand; the processed image is not showing; unless I click on second method and then come back to the first.
Thanks.
Cris LaPierre
Cris LaPierre 2020 年 9 月 22 日
編集済み: Cris LaPierre 2020 年 9 月 22 日
What is your trigger? Do you want the app to open with the linear stretching result already displayed? If so, place the following at the bottom of your startupFcn callback.
MethodButtonGroupSelectionChanged(app, app.MethodButtonGroup)

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

Mario Malic
Mario Malic 2020 年 9 月 22 日
編集済み: Mario Malic 2020 年 9 月 22 日

0 投票

  • Create property that takes Method and Contrast level values.
  • Create a callback for button group (method and image enhancement operation) - see this property (app.ImageEnhancementOperationButtonGroup.SelectedObject.Text)
  • Create a callback that sends contrast dropdown value to property.
  • Initialise starting values in startupFcn, for each component.
You read your image twice, save it in a property.

質問済み:

2020 年 9 月 17 日

編集済み:

2020 年 9 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by