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

3 次查看(过去 30 天)
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.

采纳的回答

Image Analyst
Image Analyst 2022-12-3
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by