Index in position 1 exceeds array bounds (must not exceed 1)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (2)
Askic V
le 6 Déc 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 commentaires
DGM
le 6 Déc 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 commentaires
DGM
le 6 Déc 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])
Voir également
Catégories
En savoir plus sur Graphics Object Properties dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!