Unable to perform assignment because the left and right sides have a different number of elements. Error in Esram2 (line 61) g(a+1) = g(a) - (N / D) - T; >>

1 view (last 30 days)
close all
% Data provided
load('SD_Test_Data_01.mat', 'voltage')
load('SD_Test_Data_01.mat', 'current')
I = current;
V = voltage;
P = I.*V; % To find the P-V curve
Pmaxcurve = max(P);
% Graphs
plot (V, I,'b:')
xlabel('Voltage (V)'), ylabel('Current (A)')
title('I-V Curve')
plot(V, P,'r--');
xlabel('Voltage(V)'), ylabel('Power (W)')
title('P-V Curve')
plot (V, I,'--')
title('Combine Plots')
hold on
plot(V, P, 'r:');
hold off
%At the standard test conditions (STC)
[Pmax, index_of_Pmax] = max(P);
Imp = I(index_of_Pmax); %(A)
Vmp = V(index_of_Pmax); %(v)
%We know that
Isc = max(I); %(A)
Voc = max(V); %(V)
q = 1.6022e-19; %q is the electron charge
k = 1.3806e-23; % k is the Boltzmann constant in (J/k)
% if the solar cells inside a solar module reach 65?C
T = 25; % T the module temperature in celcius
% Initializing Rs the series resistance and the shunt resistance Rsh and n
Rsh = (Vmp/(Isc- Imp))- ((Voc-Vmp)/Imp);
Rs = 0;
n= 1.2;
% Taking an assumption that Rsh>>Vo
I0 = Isc/(exp(1).*(q*(Voc/(n*k*T)))-1);
Nmax = 1000; %maximum number of interations
g(1) = 0.5; %first approximation
g = zeros(1, Nmax);
for a = 1:Nmax-1
diff_I = [0; diff(I, 1)];% zero padding to make dimensions match
N = Isc-I0.*(exp(1).*(q*((Vmp+(Imp*Rs))/n))-1) - ((Vmp+(Imp*Rs))/(n*k*T));
D = -I0.*(q/(n*k*T))*(1 + diff_I*Rs)*exp(1).*(q*(V+(I*Rs)/(n*k*T)));
T = (1/Rsh).*(1 + diff_I*Rs);
g(a+1) = g(a) - (N / D) - T;
plot(g, 'r.')

Accepted Answer

Reshma Nerella
Reshma Nerella on 13 Nov 2020
In this line of code,
g(a+1) = g(a) - (N / D) - T;
Sizes of variables are:
g(a) - 1x1 double N - 1x1 double
D - 20001x1 double T - 20001x1 double
Size of N/D - 1x20001 double
Size of (N/D-T) - 20001x20001 double
Size of (g(a) - (N / D) - T) - 20001x20001 double
You are assigning 20001x20001 double to 1x1 double.
Hence it is giving the error.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by