Unable to perform assignment because the left and right sides have a different number of elements. Kindly Help...Many thanks!

5 views (last 30 days)
I am working on a large data set(8760hrs)from an excel file:
SolRad=RaWD(:,2); WSpd =RaWD(:,3);...Grid =RaWD(:,6); etc.
I prepared the following program (extracts), but when running I got the above error:
Ppv = ones(1,8760);
for t=1:8760
Ppv(t)=epv*K(1)*SolRad(t); % power supplied by PV panels [kW]
end
Cpv=ipv*K(1);
Pw = ones(1,8760);
for t=1:8760
Pw(t)=0.5*Cp*rho*effw*K(2)*(WSpdon(t)^3); % Rated power of wind generator [kW]
end
Cw=iw*K(2);
Pg(t)= Ppv(t)+Pw(t)+Pgrid +PH(t);
SOC =ones(1,t); % Preallocation for speed
DPS = ones(1,t); % Preallocation for speed
EPG = ones(1,t);
if Pg(t)>=Pl(t)/effI % excess energy stored in the battery
SOC(t)=(SOC(t-1)*(1-dh))+((Pg(t)-(Pl(t)/effI))*ebc);
DPS(t)=0;
if SOC(t)>=SOCmax
SOC(t)=SOCmax;
EPG(t)=Pg(t)-((Pl(t)/effI)+(((SOCmax-SOC(t-1)))/ebc));
end
  5 Comments
Guillaume
Guillaume on 12 Sep 2018
Please give us the full text of the error message. Everything in red.
Unrelated to the error: None of the loops in the code you show are necessary. The first 4 lines you show can be replaced by:
PPV = epv*K(1)*SolRad; %no loop needed
assuming that SolRad is a 8760 element vector and epv is scalar. Similarly, the 2nd loop can be replaced by
Pw = 0.5*Cp*rho*effw*K(2)*Wspdon.^3; %note that .^ is required instead of ^
In addition the code after the second looks like it should have been in another loop. That loop would be more difficult to remove.

Sign in to comment.

Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!