Hi Liam,
To highlight a point on a plot that is selected from a dropdown menu , you can refer to the following code snippet.
To add a dropdown menu for the data extracted from an excel file:
function LoadButtonPushed(app, event)
[file, path] = uigetfile('data.xlsx', 'Select an Excel file');
fullPath = fullfile(path, file);
data = readmatrix(fullPath);
plot(app.UIAxes, app.xData, app.yData, 'b-');
numPoints = length(app.xData);
dropdownItems = arrayfun(@(i) sprintf('Point %d', i), 1:numPoints, 'UniformOutput', false);
app.DropDown.Items = dropdownItems;
This code opens a file selection dialog, reads data from the selected Excel file, plots the data, updates the dropdown menu with point identifiers.
Now, after populating the dropdown menu with data points, highlight the point whenever it is selected from the menu by adding a specific marker on the data point in the plot.
function PointSelectionDropDownValueChanged(app, event)
pointIndex = str2double(regexp(event.Value, '\d+', 'match', 'once'));
if ~isempty(app.HighlightedPoint) && isvalid(app.HighlightedPoint)
delete(app.HighlightedPoint);
app.HighlightedPoint = plot(app.UIAxes, app.xData(pointIndex), app.yData(pointIndex), 'ro', 'MarkerSize', 10);
You might find these resources helpful:
Hope this helps!