pts] create a menu to select a year from the year variable. in matlab

main.m
years = [2022, 2023, 2024, 2025];
options = string(years);

f = figure('Name','Select Year','NumberTitle','off','Position',[100 100 250 100]);

h = uicontrol('Style','popupmenu','String',options,'Position',[50 50 150 30]);

selectedYear = str2double(options(get(h,'Value')));

disp(['Selected year: ', num2str(selectedYear)]);
327 chars
11 lines

related categories

gistlibby LogSnag