How do you connect Drop Down on design app to your function

2 views (last 30 days)
I have a function that gives random colors to random squares (6x6 matrix).
n = 6; % number of squares along x and y
% create the figure
figure;
hold on;
axis equal;
% width of square divided by two
sqrWidthBy2 = 0.5;
% set the axis limits
axis([sqrWidthBy2 n+sqrWidthBy2 sqrWidthBy2 n+sqrWidthBy2]);
% array for the fill graphic object handles
sqHandles = zeros(n,n);
% array of colours (white/blank, red, green)
colours = ['r','g','b'];
% loops to create the squares
for x=1:n
for y=1:n
clr = colours(randi(3));
sqHandles(x,y) = fill([x-sqrWidthBy2 x+sqrWidthBy2 x+sqrWidthBy2 x-sqrWidthBy2 x-sqrWidthBy2],...
[y-sqrWidthBy2 y-sqrWidthBy2 y+sqrWidthBy2 y+sqrWidthBy2 y-sqrWidthBy2],clr);
end
end
I want to create a drop down on design APP using GUI that way if i choose "10% red", than 10% of the matrix turns 0.1 red and if choose 50% red than 0.5 red. And i want to create 3 drop down (1 for each color). So if i choose "30% red, 30% blue and 30% green." Than 30% of the matrix turns each different color randomly. And if they end up in the same grid than they combine colors, thats fine too.
Im just not being able to assign colors to each drop down or even be able to assign a number to each square for that square alone to change colors. Any help would be greatly appreciated.

Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!