Simulink Model Error - Please Help

2 views (last 30 days)
Shraddha
Shraddha on 7 Aug 2024
Answered: Kautuk Raj on 13 Aug 2024
Can u please help solve this error ?

Answers (1)

Kautuk Raj
Kautuk Raj on 13 Aug 2024
I understand that you are encountering an error while compiling a Simscape network for your model, specifically related to the "PS Lookup Table (1D)1" block in the "Model/SOLAR PV/Electrolyzer" subsystem.
It is required that all branches of a conditional expression must have consistent types (including size and unit) in the Simscape language. The compiler translates all branches regardless of being active or not. The equations defined inside a conditional section are not subject to this constraint, for example:
component getT
inputs
T = 0;
end
outputs
y = zeros(size(table_T'));
end
parameters
table_T = [1 2 3 4]';
table_val = [1 2 3 4]';
end
parameters(Access=private)
N = size(table_val,2);
end
% equations declared inside a conditional section are not subject to this constraint.
% In this case, only the active branch will be inclused in the system.
if N==1
equations
y == tablelookup(table_T, table_val, T, interpolation = linear, extrapolation = nearest);
end
else
equations
assert(ndims(table_val)==2);
y == tablelookup(table_T,1:N,table_val,ones(1,N)*T,1:N, interpolation = linear, extrapolation =
nearest);
end
end
end
component MyComp
inputs
T = 0;
end
outputs
y = zeros(size(table_T'));
end
parameters
table_T = [1 2 3 4]';
table_val = [1:4; 5:8; 9:12; 13:16];
end
components(ExternalAccess=observe)
getT = getT(table_T=table_T, table_val=table_val);
end
equations
T == getT.T;
y == getT.y;
end
end
However, one may only use conditional sections in a component class and not in Simscape functions.
I trust this response will guide you towards resolving your query.

Categories

Find more on Simulink in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!