Error in Simulink , output sizes of the block

85 次查看(过去 30 天)
Hello;
I've tried to writing matlab code for determining global peaks for shading pv panel and set the output as maximum power, region and short circuit current to be used in next block. My inputs are PV voltage and current from PV block, both are 3000x1 double sizes.
However, when I run the program it shows the error of
_Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and/or sizes for the block output_ s.
I expected the outputs to be single number.
The code is below;
function [Region,Isc_step,P_Gmppt] = initial(V1, I1)
P1= V1.*I1;
[P_Lmppt,V_Lmppt] = findpeaks(P1,V1);
P_Gmppt = max(P_Lmppt); % find global max
V_Gmppt_loc = find(P_Gmppt == P_Lmppt);
V_Gmppt = V_Lmppt(V_Gmppt_loc); % find V at global max
P_inv = P_Gmppt - P1; % inverse the data
[P_drop_Lmppt,V_drop_Lmppt] =findpeaks(P_inv,V1);
V_drop = max(V_drop_Lmppt);
V_drop_loc = find(V1 == V_drop);
P_drop = P_inv(V_drop_loc);
% calculate shading short circuit current (after step)
I_shade = I1(V_drop_loc:end,:); % filter I that beyond V_drop
V_shade = V1(V_drop_loc:end,:); % filter I that beyond V_drop
Isc_step = I_shade(1);
if V_Gmppt > V_drop
Region = 1;
else
Region = 2;
end
end
The figure for simulink is
Any suggestions for solving this? Many thanks in Advanced

采纳的回答

Birdman
Birdman 2017-11-20
Make three assignments at the beginning of your function: If the outputs are scalar
Region=0;
Isc_step=0;
P_Gmppt=0;
If vector
Region=zeros(n,1);
Isc_step=zeros(n,1);
P_Gmppt=zeros(n,1)%n is the row number you define
By this way, Simulink has an idea of what type and dimension the output is going to be.
  5 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Electrical Sensors 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by