Problem with 2 plots, one in not showing and second one is showing up empty.
Show older comments
hello,
so I have 2 small codes, with 2 plots, the first one is showing the plot empty and the second one is not showing at all, can anyone help me please,
thanks,
first code:
Ppvmax= 800; % watt/m^2
Tdl= 12; %daytime duration
Tsr=7; % sunrise time
Ttod daytime at time of day
for Ttod=[0:1:24];
Ppv = Ppvmax * sin( pi*(Ttod-Tsr)/Tdl );
plot(Ttod,Ppv)
hold on;
end
second code:
Pfdg=50;
Pfz= 22; PLi=267; Psh= 313; Pac=403; Ptv=86; Pwm=1.2; Pmicro=0.33; Pnot= 13; Pwater=8.5;
for t=[0:1:24]
if 5<t<8
a=0
else a=1;
end
if 17<t<21
b=0
else b=1
Pdem = symsum(Pfdg,0,24) + Pfz + PLi + a*Psh + b*Psh + a*Pac + b*Pac + a*Ptv + b*Ptv + a*Pnot + b*Pnot + a*b*Pwater +a*b*Pwm + Pmicro
plot(t,Pdem)
hold on;
end
end
2 Comments
Ppvmax= 800; % watt/m^2
Tdl= 12; %daytime duration
Tsr=7; % sunrise time
Ttod=[0:1:24];
Ppv = Ppvmax * sin( pi*(Ttod-Tsr)/Tdl );
plot(Ttod,Ppv)
hold on;
Pfdg=50;
Pfz= 22; PLi=267; Psh= 313; Pac=403; Ptv=86; Pwm=1.2; Pmicro=0.33; Pnot= 13; Pwater=8.5;
t=Ttod; % just to save redefining variable t below
a=zeros(size(t)); a(t>=8)=1; % define constant by TOD
b=ones(size(t)); b(t>17 & t<21)=0;
Pdem=Pfdg+Pfz+PLi+(a+b)*(Psh+Pac+Ptv+Pnot)+a.*b*(Pwater+Pwm) + Pmicro;
plot(t,Pdemsum
jana nassereddine
on 19 May 2023
Accepted Answer
More Answers (1)
You need to include a markerstyle in your plot commands since you are plotting your data one point at a time. When you plot a single point without a marker, it is not visible.
The other option is to use your for loop to create a vector, and then plot the vector.
In your second case, you should specifly your if statements and two conditions. You will then have the same issue with plotting a single point at a time.
t=0;
% Always true
5<t<8
% specifying as two conditions
t>5 && t<8
Categories
Find more on Special Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!