Create an Array with zeroes and sevens

2 visualizaciones (últimos 30 días)
Sophie Chumas
Sophie Chumas el 19 de En. de 2020
Respondida: dpb el 19 de En. de 2020
Hi,
background: i'm trying to model a vehicle charging profile that has a charger rating of 7kW, a charging time drawn from a uniform distribution between 0.5hr to 4hrs, and a start time drawn from normal distribution with mean 5pm and s.d. 0.5hrs. This data needs to then be added to a data matrix containing kWh usage of 5903 customers (in the layout of 48 x 5903). It then needs to be repeated for (0.03 x 5903) customers - ie. a charging profile for each customer is added to the data...Everything is calculated in half hours.
I've been trying to find the charging profile for just one customer (as a starting point) but have gotten stuck as to how I can add this to the data. So, the million dollar question is: how do I create an array containing zeroes that's 1x48 (48 hhs) but contains a block of charger ratings i.e. the charger is rated 7kW so if it's used for say 3hours starting at the 2 hh, the array returned would be: [0 7 7 7 7 7 7 0 0 0 0 0 0 0 0 0 0 0....] so it can then be added to the original load of the customer?
Hope this makes sense! Then how would I turn it into a function where I declare the market penetration, it then calculates the number of customers required to add EV loading profiles to, and then adds the EV loading profiles to each of them?
Thanks!! :)
Code so far:
market_pen = 0.03;
number_customers = market_pen * 5903;
%need to write function that repeats next bit * number_customers
customer = randi(5903);
rand_customer_load = load_day(:,customer);
charger_rating = 7;
start_time = round(normrnd(34,0.5));
duration_array = [0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4];
duration = duration_array(randi(length(duration_array)));
EV_load =
new_customer_load = (rand_customer_load + EV_load);

Respuestas (1)

dpb
dpb el 19 de En. de 2020
function charge=chargeprofile(start,chargetime,kW)
% return charging profile for half hour increments over 24-hr day
% given start time in nearest half hour increment on 24-hr clock,
% "on" time (assumed contiguous) in hours/fraction hours and
% charger power rating.
charge=zeros(1,48); % initialize
tstart=round(start*2)/2; % round nearest half hour
chargetime=round(chargetime*2)/2; % ditto
t1=tstart*2;
charge(t1:t1+2*chargetime-1)=kW;
return
Can simplify some of the intermediates but left explicit for clarity in logic...

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by