Index in position 1 exceeds array bounds (must not exceed 1)

1 vue (au cours des 30 derniers jours)
Jem Jem
Jem Jem le 6 Déc 2022
Commenté : DGM le 6 Déc 2022
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

Réponses (2)

Askic V
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.

DGM
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
Jem Jem
Jem Jem le 6 Déc 2022
but, I assumed that PV = 73 mean PV = 0:73 for 0:23 time interval
DGM
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])
PV = 4×24
0 3.1739 6.3478 9.5217 12.6957 15.8696 19.0435 22.2174 25.3913 28.5652 31.7391 34.9130 38.0870 41.2609 44.4348 47.6087 50.7826 53.9565 57.1304 60.3043 63.4783 66.6522 69.8261 73.0000 0 3.1739 6.3478 9.5217 12.6957 15.8696 19.0435 22.2174 25.3913 28.5652 31.7391 34.9130 38.0870 41.2609 44.4348 47.6087 50.7826 53.9565 57.1304 60.3043 63.4783 66.6522 69.8261 73.0000 0 3.1739 6.3478 9.5217 12.6957 15.8696 19.0435 22.2174 25.3913 28.5652 31.7391 34.9130 38.0870 41.2609 44.4348 47.6087 50.7826 53.9565 57.1304 60.3043 63.4783 66.6522 69.8261 73.0000 0 3.1739 6.3478 9.5217 12.6957 15.8696 19.0435 22.2174 25.3913 28.5652 31.7391 34.9130 38.0870 41.2609 44.4348 47.6087 50.7826 53.9565 57.1304 60.3043 63.4783 66.6522 69.8261 73.0000
L = repmat(L,[1 T])
L = 4×24
75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 75 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 68 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153 153

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by