Index in position 1 exceeds array bounds (must not exceed 1)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I need to run the following dada, but I facing this error "Index in position 1 exceeds array bounds (must not exceed 1)".
I used PV power output is same for each house, but different load demand for each house in 24 hour interval, and I tried to get that the (output power, load demand) versus (Time in 24 houre) for each H house. Any adea how to fix the error? Thank you in advance!
Remember, the PV out put is same for each House,
clear all
clc
close all
T = 24; % hour
H =4; %house
PV(:,1) = 73; %PV output power/House
L(:,1) = [75; 42; 68; 153];%Load Demand power/House
for t = 1:T
for h = 1:H
PV(h,t+1) = PV(h,t);
L(h,t+1) = L(h,t);
end
end
figure
subplot(4,1,1);
plot(0:23,PV(1,:),'-*b',0:23,L(1,:),'-*r','Linewidth',1);hold on
xlabel('Time in 24 houre')
ylabel('Power')
legend('PV Output', 'Load Demand')
title('H1')
subplot(4,1,2);
plot(0:23,PV(1,:),'-*b',0:23,L(2,:),'-*r','Linewidth',1);hold on
xlabel('Time in 24 houre')
ylabel('Power')
legend('PV Output', 'Load Demand')
title('H2')
subplot(4,1,3);
plot(0:23,P_PV(1,:),'-*b',0:23,L(3,:),'-*r','Linewidth',1);hold on
xlabel('Time in 24 houre')
ylabel('Power')
legend('PV Output', 'Load Demand')
title('H3')
subplot(4,1,4);
plot(0:23,P_PV(1,:),'-*b',0:23,L(4,:),'-*r','Linewidth',1);hold on
xlabel('Time in 24 houre')
ylabel('Power')
legend('PV Output', 'Load Demand')
title('H4')
hold off
0 comentarios
Respuestas (2)
Askic V
el 6 de Dic. de 2022
Here in the loop:
for t = 1:T
for h = 1:H
PV(h,t+1) = PV(h,t);
You're trying to access PV(2,1), when PV is PV = 73 73, so 1x2 in dimensions.
0 comentarios
DGM
el 6 de Dic. de 2022
It's unclear why you'd want to plot a bunch of constants, but this is apparently the same as what you're trying to do.
T = 24; % hour
H = 4; %house
PV = 73; %PV output power/House
L = [75; 42; 68; 153];%Load Demand power/House
PV = repmat(PV,[H T]);
L = repmat(L,[1 T]);
% ...
2 comentarios
DGM
el 6 de Dic. de 2022
You mean like this? I don't know why it'd be a linear ramp either.
T = 24; % hour
H = 4; %house
PV = linspace(0,73,T); %PV output power/House
L = [75; 42; 68; 153];%Load Demand power/House
PV = repmat(PV,[H 1])
L = repmat(L,[1 T])
Ver también
Categorías
Más información sobre Graphics Object Properties 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!