Effacer les filtres
Effacer les filtres

How can I iteract a RGB Vector between a script and a GUI

2 vues (au cours des 30 derniers jours)
Jan Hörber
Jan Hörber le 11 Jan 2022
Réponse apportée : Ninad le 28 Sep 2023
Hello,
I tried to exchange a RGB Color information between a Variable from a Script into a Matlab GUI. I used to try it withe the getappdata function but it didn't worked.
The The RGB Color information gets sorted out to a text string (green, blue, red) and then should be transfert to a GUI to change a lamp into the transfered color. How does ist work?
Thanks in advance

Réponses (1)

Ninad
Ninad le 28 Sep 2023
Hi Jan,
You can use the setappdata” and “getappdata” functions to exchange color information between a MATLAB script and the application.
I have made a dummy application using two files, "script.m" and "gui.m":
  1. The "script.m" file stores the RGB colour information in three different variables named "blueColor",greenColor”, and “redColor”. The “setappdata” function is used in this script to store the data in the User Interface.
  2. The "gui.m" file is used to create the user interface with three buttons named “Blue”, “Green”, and “Red. Every button will trigger a different callback function when pressed. Within the callback function, the “getappdata” function is used to retrieve the variable values that were passed from the "script.m" file. Then, the color of the application is changed using the “set” function.
This is what the User Interface will look like:
I have attached the scripts with this answer. Run the scripts in the following order
  • script.m
  • gui.m
You may refer the following documentations to understand the usage of these functions in detail:
Thanks,
Ninad.

Catégories

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

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by