Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Image Analyst
Image Analyst am 3 Dez. 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.
  1 Kommentar
Dominik
Dominik am 4 Dez. 2022
Thank you very much, this helps a lot since i wasn't really sure how to do it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by