Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

I am writing code to create a GUI, so How do I set slider values to change RGB axes values?

1 view (last 30 days)
I am writing code to create a GUI.
The guidelines are as listed:
So first, open up App Designer in Matlab.
Then create a new GUI and in the “Design View” tab, place all the components for the GUI
  • 3 Sliders
  • 1 Axis
  • 1 Button
  • 1 Label
  • Add a CallBack function for the Button
Next, go to the “Code View” tab, and add the code for the Button callback function so that the background color of the Axes changes based on the value of the sliders AND the values of the sliders are printed. This callback function will be executed when the Update Color Button is pushed.
  • The values from the sliders can be saved as variables by storing the “.Value” property
  • The color of the axes can be changed by setting the “.Color” property to the RGB values from the sliders
  • Use the sprintf function to print the values for R, G and B to the Label component by setting the .Text property. The sprintf function works very similar to fprintf -- but instead of printing to the Command Window, sprintf prints to a char Array variable.
I followed these guidelines and have the Design View of:
and a Code View of:
It is not working and I am unsure how to set the values of the sliders to ensure that they change the axes background color. Help would be greatly appreciated. Thank you for yor time!
  4 Comments
Me
Me on 18 Nov 2022
Edited: Me on 18 Nov 2022
Sorry, I noticed you said use callback of the sliders. If I were to do that, what information would need to be present in those sliders? Would each slider need to be set to app.UIAxes.BackgroundColor = [RVal, GVal, BVal]? The guidelines instruct me to use the button callback to change the background color and print to the label. Would I instead set each value of the slider within each slider's callback?
Jan
Jan on 18 Nov 2022
Sorry, I've struggled to much with the tiny screenshots. No, do not use thecallbacks of the sliders, but the callbacl of the button. Currently you have com code in the UIFigureButtonUp callback, but this is not useful.

Answers (0)

This question is closed.

Products

Community Treasure Hunt

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

Start Hunting!