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

1 次查看(过去 30 天)
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
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 中查找有关 String Parsing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by