How to calculate P at each x values?

5 views (last 30 days)
MUNKHBOLOR BAIGALI
MUNKHBOLOR BAIGALI on 11 Sep 2020
Answered: Ayush Gupta on 15 Sep 2020
Hello.
I tried to calculate P. Please help me
function [Tc, P] = myfun2()
Ppv_rated = 250;
G = [5.75, 6, 6.365, 6.5, 6.185, 5.75, 5, 4.8, 5.5, 6.18, 6.15, 5.8];
Gref = 1000;
Kt = -0.485;
Tref = 25;
Tamb = [25.63, 26.7, 26.610, 25.46, 24.9, 24.01, 23.16, 23.01, 23.54, 23.78, 24.45, 25.3];
x = [0 2 5 7 8 9 10];
for i = 1:length(x)
for j = 1:length(Tamb)
Tc(j)= Tamb(j) + 0.0256*G(j);
P(i,j) = Ppv_rated*x(i)*(G(j)/Gref)*(1+Kt*(Tc(j)-Tref));
end
end
But Result is
The results is correct. BUT I want to calculate like this:
x1 = 0
P1 = Ppv_rated * x1 * (G1/Gref) * (1 + Kt * (Tc1 -Tref))
P2 = Ppv_rated * x1 * (G2/Gref) * (1 + Kt * (Tc2 -Tref))
...
...
P12 = Ppv_rated * x1 * (G12/Gref) * (1 + Kt * (Tc12 -Tref))
x2 = 2
P1 = Ppv_rated * x2 * (G1/Gref) * (1 + Kt * (Tc1 -Tref))
P2 = Ppv_rated * x2 * (G2/Gref) * (1 + Kt * (Tc2 -Tref))
...
...
P12 = Ppv_rated * x1 * (G12/Gref) * (1 + Kt * (Tc12 -Tref))
x7 = 10
P1 = Ppv_rated * x7 * (G1/Gref) * (1 + Kt * (Tc1 -Tref))
P2 = Ppv_rated * x7 * (G2/Gref) * (1 + Kt * (Tc2 -Tref))
...
...
P12 = Ppv_rated * x7 * (G12/Gref) * (1 + Kt * (Tc12 -Tref))
How do I do??? PLEASE HELP !!!

Answers (1)

Ayush Gupta
Ayush Gupta on 15 Sep 2020
The problem with the approach suggested above is only the values of last iteration of x will be stored in P values. So, to keep the record of all iterations previously, refer to this code:
P(j,i) = Ppv_rated*x(i)*(G(j)/Gref)*(1+Kt*(Tc(j)-Tref));

Categories

Find more on Mathematics and Optimization in Help Center and File Exchange

Tags

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!