Trying to get certain values from an excel file as user input

2 views (last 30 days)
Hi,
I need to make a code that would ask user to choose range of days (Datum), and than choose another value (from B to H) and make graph out of these values. Also the are lot of empty brackets so im not sure if it would be better to use xlsread or readtable.
Any help would be appreciated.

Accepted Answer

Image Analyst
Image Analyst on 3 Dec 2022
You should probably use readtable or readmatrix since xlsread is deprecated.
You should probably plot one or more curves first, before asking the user, so they know what values of Datum to specify.
To ask a user for two floating point numbers, see this snippet:
% Ask user for two floating point numbers.
defaultValue = {'6.3.2020', '18.3.2020'};
titleBar = 'Enter values';
userPrompt = {'Enter date 1 : ', 'Enter date 2: '};
caUserInput = inputdlg(userPrompt, titleBar, 1, defaultValue);
if isempty(caUserInput),return,end % Bail out if they clicked Cancel.
% Convert to floating point from string.
usersValue1 = str2double(caUserInput{1})
usersValue2 = str2double(caUserInput{2})
You might want to convert the dates to numbers to get the row index of those dates. They've been changing the date manipulation functions so much over the past few years, it's hard to keep track of the best, recommended functions to use to do that so you'll have to do a little research on that.

More Answers (0)

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!