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

조회 수: 1 (최근 30일)
Jan Hörber
Jan Hörber 2022년 1월 11일
답변: Ninad 2023년 9월 28일
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

답변 (1개)

Ninad
Ninad 2023년 9월 28일
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.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by