how to store the data in table after running if loop

4 views (last 30 days)
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 Comment
Ram Basnet
Ram Basnet on 3 May 2021
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.

Sign in to comment.

Accepted Answer

Cris LaPierre
Cris LaPierre on 3 May 2021
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.

More Answers (0)

Categories

Find more on Language Fundamentals in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!