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

조회 수: 2 (최근 30일)
Phelipe De Sousa
Phelipe De Sousa 2020년 3월 26일
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.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by