how to store the data in table after running if loop

1 visualización (últimos 30 días)
Ram Basnet
Ram Basnet el 3 de Mayo de 2021
Respondida: Cris LaPierre el 3 de Mayo de 2021
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 comentario
Ram Basnet
Ram Basnet el 3 de Mayo de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 3 de Mayo de 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.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by