Problem to converge a loop in Simulink

3 Ansichten (letzte 30 Tage)
Raúl Rivera
Raúl Rivera am 17 Jan. 2025
Beantwortet: Kanishk am 27 Jan. 2025
Hello , I want to simulate a close circuit that consist on a grinding mill next to hydrocyclon and have the following problem with the code that joins two flows tabla1 of dimension 11x5 and TablaFlujo1 of dimension 2x3 are from the input flow, while tabla2 of dimension 11x5 and TablaFlow2 of dimension 2x3 are from the recirculated flow(very important to remark because it causes a loop) from the whole process and in this code they are added together to form a single flow named TablaGranulometrica and TablaFlujo . i tried to initialize the recirculated flow with the desired size,and so the output stream ,but pops a error instead : "Block ''granulometria4/Subsystem3/MATLAB Function5'' does not fully set the dimensions of output 'TablaFlujo'."
I will give attach a screenshot :
I really dont know how to make it converge or at least give an initial condition so it start running . Below is the function script , will also attach the full file. thanks in advance.
function [TablaGranulometrica, TablaFlujo, total,convergencia] = fcn(tabla1, TablaFlujo1, tabla2, TablaFlujo2,epsilon)
if size(tabla2)~=size(tabla2)
tabla2 = tabla1; % Inicializa tabla2 como matriz de ceros del mismo tamaño que tabla1
end
if size(TablaFlujo1)~=size(TablaFlujo2)
TablaFlujo2 = (TablaFlujo1); % Inicializa TablaFlujo2 como matriz de ceros del mismo tamaño que TablaFlujo1
end
% Tabla Granulométrica
TablaGranulometrica = tabla1;
TablaGranulometrica(:,2) = tabla1(:,2) + tabla2(:,2);
total = sum(TablaGranulometrica(:, 2));
TablaGranulometrica(:, 3) = (TablaGranulometrica(:, 2) / total) * 100;
TablaGranulometrica(:, 4) = cumsum(TablaGranulometrica(:, 3));
TablaGranulometrica(:, 5) = 100 - TablaGranulometrica(:, 4);
% Tabla de Flujo
TablaFlujo = size(2, 3); % Dimensiones fijas [2x3]
TablaFlujo = zeros(size(TablaFlujo1)); % Inicializa la salida
TablaFlujo(1,1) = TablaFlujo1(1,1) + TablaFlujo2(1,1);
TablaFlujo(2,3) = TablaFlujo1(2,3) + TablaFlujo2(2,3);
TablaFlujo(2,2) = (TablaFlujo(1,1) / 2.45) + TablaFlujo(2,3);
TablaFlujo(2,1) = 100 * TablaFlujo(1,1) / (TablaFlujo(1,1) + TablaFlujo(2,3));
TablaFlujo(1,2) = 100 * (TablaFlujo(1,1)) / (TablaFlujo(2,1) * TablaFlujo(2,2));
TablaFlujo(1,3) = 2.45;
% Cálculo final de total
total = sum(TablaGranulometrica(:,2)) * 24;
error_tabla = max(abs(tabla1(:,2) - tabla2(:,2)));
error_flujo = max(abs(TablaFlujo1(:,1) - TablaFlujo2(:,1)));
convergencia = (error_tabla < epsilon) && (error_flujo < epsilon);
end

Akzeptierte Antwort

Kanishk
Kanishk am 27 Jan. 2025
I understand you are using MATLAB function blocks in Simulink and facing an error regarding dimensions of "TableFlujo". The error corresponds to Simulink not able to infer the size of "TableFlujo" in "MATLAB Function5". You can resolve this error by manually setting the size of "TableFlujo" to "[2 3]" from the "Model Explorer".
You can access "Model Explorer" either from toolstrip (Modelling > Design) or by right-clicking on the MATLAB Function Block > Explore.
Simulating the model at this stage presents another error as it still contains algebraic loop. The algebraic loop can be resolved by adding a unit delay block in the model.
You can learn more resolving algebraic loops in Simulink by following this official MathWorks Documentation.
Hope this helps!

Weitere Antworten (0)

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by