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

1 vue (au cours des 30 derniers jours)
Phelipe De Sousa
Phelipe De Sousa le 26 Mar 2020
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.

Réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by