HI
how i change the color map of figure in GUI by ListBox Items:{ jet hot cool .....} using GUI

3 Kommentare

yasmeen hadadd
yasmeen hadadd am 23 Jul. 2024
Bearbeitet: Walter Roberson am 23 Jul. 2024
function ColormapListBoxValueChanged(app, event)
% value = app.ColormapListBox.Value;
% Get the selected colormap from the Listbox
Items = {'jet', 'hsv', 'hot', 'cool'};
selected_colormap = Items{app.ColormapListBox.Value};
% Switch-case to change colormap based on selected_colormap
switch selected_colormap
case 'jet'
colormap(app.UIAxes, jet);
case 'hsv'
colormap(app.UIAxes, hsv);
case 'hot'
colormap(app.UIAxes, hot);
case 'cool'
colormap(app.UIAxes, cool);
end
this is cide but not working , what is the wrong?
selected_colormap = Items{app.ColormapListBox.Value};
That should be
selected_colormap = Items{app.ColormapListBox.ValueIndex};
Better would be
function ColormapListBoxValueChanged(app, event)
selected_colormap = app.ColormapListBox.Value;
colormap(app.UIAxes, selected_colormap)
end

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 23 Jul. 2024

0 Stimmen

Create a listbox with the colormap names. Set the callback for the listbox to execute
Colormap_name = app.LISTBOXNAME.Value;
colormap(app.FIGURENAME, Colormap_name);

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Hilfe-Center und File Exchange

Produkte

Gefragt:

am 23 Jul. 2024

Kommentiert:

am 23 Jul. 2024

Community Treasure Hunt

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

Start Hunting!

Translated by