Colors in Matlab as a vriable

5 visualizaciones (últimos 30 días)
Rao Maaz Bin Khalid
Rao Maaz Bin Khalid el 12 de En. de 2021
Respondida: Steven Lord el 12 de En. de 2021
I want the user to choose a color from a menu for my object. Can someone please suggest what the best way to do it is?
My object is in another function which I have called in the main script. The menu is also inside the function.
Part of Function:
Auto.Farbe = menu ('Wählen Sie eine Autofarbe aus' ,'Red','Yellow','Green');
Main script:
Farbe = Auto.Farbe;
patch('Vertices',Auto.Ecken,'Faces',Auto.Karosseire_Flaechen,'FaceColor',Farbe)
Any leads will be highly appreciated.

Respuestas (2)

Stephen23
Stephen23 el 12 de En. de 2021
Editada: Stephen23 el 12 de En. de 2021
Perhaps something like this:
M = [1,0,0;... red
1,1,0;... yellow
0,1,0]; % green
X = strcmpi(Auto.Farbe,{'red','yellow','green'});
Farbe = M(X,:);
Or else download this:
and use it something like this:
[~,Farbe] = colornames('CSS',Auto.Farbe)

Steven Lord
Steven Lord el 12 de En. de 2021
Do you want your users to select colors by name or by appearance? If the latter use uisetcolor.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by