how to store the data in table after running if loop

2 次查看(过去 30 天)
clear
data = readtable("hourlyrate_electricity.csv")
data1 = data.GB_GBN_price_day_ahead;
data2= data.GB_GBN_load_actual_entsoe_transparency;
dates_extracted1 = data.utc_timestamp;
dates_extracted = [data.utc_timestamp];
dates= cell2table(dates_extracted);
dates1= datetime(dates.dates_extracted,"InputFormat","uuuu-MM-dd'T'HH:mm:ssZ", "TimeZone", "Z");
c= datenum(dates1);
dm= table(data1, data2,c);
dm2= table2array(dm)
ReplacedmissingValue= standardizeMissing(dm2,0);
display(ReplacedmissingValue)
x= rmmissing(ReplacedmissingValue)
datesbb= x(:,3);
b= datetime(datesbb,'ConvertFrom','datenum');
price= x(:,1);
used_data= table(b,price)
rows_price= height(used_data);
for i=1:rows_price
isa=(used_data.b.Hour==8)
if any(isa)
eight_date=used_data{i,1};
eight_price=used_data{i,2};
end
end
  1 个评论
Ram Basnet
Ram Basnet 2021-5-3
i wanna store all the data from the table which satisfy if condition but i end up just storing the last dataset of the loop.

请先登录,再进行评论。

采纳的回答

Cris LaPierre
Cris LaPierre 2021-5-3
You need to assign the results from each look to a matrix. See this example.
You can learn more about for loops in Ch 13 of MATLAB Onramp.

更多回答(0 个)

类别

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

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by