필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
Dominik
Dominik 2022년 12월 3일
댓글: Dominik 2022년 12월 4일
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.
  댓글 수: 1
Dominik
Dominik 2022년 12월 4일
Thank you very much, this helps a lot since i wasn't really sure how to do it.

댓글을 달려면 로그인하십시오.

추가 답변 (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