How to remove cell data from specific column using dates as a reference?

조회 수: 2 (최근 30일)
muhammad choudhry
muhammad choudhry 2022년 8월 2일
편집: Chunru 2022년 8월 2일
Hi,
I am analysing the flowrate data in which there are fluctuations due to errors. I would like to remove the errors using dates as a reference. Currently I am just doing manually in excel. Is there any easy way to do in matlab? With the file attached I am trying to remove the data from 11/05/2020 till 28/09/2020 of flowrate_5 (in a flowrate tab). cells and want them cells to be empty. your help would be much appreciated.
Code:
file_list = readtable('flowrate_dates.xlsx','flowrate');
I am googling but not getting more then one line, I can further mention the cell range but i want to remove the data using the date range which I do not know how to do it.

답변 (1개)

Chunru
Chunru 2022년 8월 2일
편집: Chunru 2022년 8월 2일
T = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1085695/flowrate_dates.xlsx", "Sheet", 3)
T = 365×11 table
Dates Flowrate_1 Flowrate_2 Flowrate_3 Flowrate_4 Flowrate_5 Flowrate_6 Flowrate_7 Flowrate_8 Flowrate_9 Flowrate_10 ___________ __________ __________ __________ __________ __________ __________ __________ __________ __________ ___________ 01-Apr-2020 100 100 100 100 100 100 100 100 100 100 02-Apr-2020 100 100 100 100 100 100 100 100 100 100 03-Apr-2020 100 100 100 100 100 100 100 100 100 100 04-Apr-2020 100 100 100 100 100 100 100 100 100 100 05-Apr-2020 100 100 100 100 100 100 100 100 100 100 06-Apr-2020 100 100 100 100 100 100 100 100 100 100 07-Apr-2020 100 100 100 100 100 100 100 100 100 100 08-Apr-2020 100 100 100 100 100 100 100 100 100 100 09-Apr-2020 100 100 100 100 100 100 100 100 100 100 10-Apr-2020 100 100 100 100 100 100 100 100 100 100 11-Apr-2020 100 100 100 100 100 100 100 100 100 100 12-Apr-2020 100 100 100 100 100 100 100 100 100 100 13-Apr-2020 100 100 100 100 100 100 100 100 100 100 14-Apr-2020 100 100 100 100 100 100 100 100 100 100 15-Apr-2020 100 100 100 100 100 100 100 100 100 100 16-Apr-2020 100 100 100 100 100 100 100 100 100 100
idx = T.Dates >= datetime('11/05/2020', 'InputFormat', 'dd/MM/yyyy') & ...
T.Dates <= datetime('28/09/2020', 'InputFormat', 'dd/MM/yyyy');
%T(idx, :) =[];
T.Flowrate_5(idx) = nan;
T(30:50,:)
ans = 21×11 table
Dates Flowrate_1 Flowrate_2 Flowrate_3 Flowrate_4 Flowrate_5 Flowrate_6 Flowrate_7 Flowrate_8 Flowrate_9 Flowrate_10 ___________ __________ __________ __________ __________ __________ __________ __________ __________ __________ ___________ 30-Apr-2020 100 100 100 100 100 100 100 100 100 100 01-May-2020 800 800 800 800 800 800 800 800 800 800 02-May-2020 800 800 800 800 800 800 800 800 800 800 03-May-2020 800 800 800 800 800 800 800 800 800 800 04-May-2020 800 800 800 800 800 800 800 800 800 800 05-May-2020 800 800 800 800 800 800 800 800 800 800 06-May-2020 800 800 800 800 800 800 800 800 800 800 07-May-2020 800 800 800 800 800 800 800 800 800 800 08-May-2020 800 800 800 800 800 800 800 800 800 800 09-May-2020 800 800 800 800 800 800 800 800 800 800 10-May-2020 800 800 800 800 800 800 800 800 800 800 11-May-2020 800 800 800 800 NaN 800 800 800 800 800 12-May-2020 800 800 800 800 NaN 800 800 800 800 800 13-May-2020 800 800 800 800 NaN 800 800 800 800 800 14-May-2020 800 800 800 800 NaN 800 800 800 800 800 15-May-2020 800 800 800 800 NaN 800 800 800 800 800
  댓글 수: 2
muhammad choudhry
muhammad choudhry 2022년 8월 2일
편집: muhammad choudhry 2022년 8월 2일
Hi, thanks for the reply. you have separated the data. Please see the attached screenshot thats what I want. values removed from that specific column called flowrate_5 and values removed from the range of 11/05/2020 to 28/09/2020 with leaving empty cells in the space so whenever I do plotting it will show me rest of the data except the empty spaces.Also you have pick the pressure tab from the excel file.
Chunru
Chunru 2022년 8월 2일
If you eant to "remove" the values for flowrate_5 within the period specified while keeping other columns, you can assign the nan value for them. See updated above.

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

카테고리

Help CenterFile Exchange에서 Calendar에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by