Hi, I was stuck here.. can someone help me out? How do I make the Pbat1 and Pbat2 smooth?
P_load = [0,8000,10000,11000,20000,25000,25000,21000,30000,20000,12000,45000,12000,45000,23300,12000,15000,17000,20000,16000,12200,1000,2000,100];% Watts
plot(P_load,'linewidth', 2)P_gen = ones(1,24).*29000; % WattsP_lowerlimit = ones(1,24).*10000; % Wattshold on plot(P_gen, 'linewidth', 2)plot(P_lowerlimit, 'linewidth', 2)gridxlim([1,24])xlabel('Time (hours)')ylabel('Power (Watts)')hold onPnet1 = [];Pbat1 = [];Pnet2 = [];Pbat2 = [];for h = 1:24 Pnet1(h) = P_gen(h) - P_load(h); Pnet2(h) = P_lowerlimit(h) - P_load(h); if Pnet1(h) > 0 Pbat1(h) = 0; else Pbat1(h) = P_load(h) - P_gen(h); end if Pnet2(h) < 0 Pbat2(h) = 0; else Pbat2(h) = [P_gen(h) - P_load(h)]/3; endendplot(Pbat1, 'linewidth', 3)plot(Pbat2, 'linewidth', 3)legend('Load','Generator','Lower limit','Battery energy(Discharge)','Battery energy(Charge)')
If possible, i need with spline code. Help appreciated, thank you.
Best Answer