Problem to converge a loop in Simulink
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 11×5 and TablaFlujo1 of dimension 2×3 are from the input flow, while tabla2 of dimension 11×5 and TablaFlow2 of dimension 2×3 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 [2×3]
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);
endHello , 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 11×5 and TablaFlujo1 of dimension 2×3 are from the input flow, while tabla2 of dimension 11×5 and TablaFlow2 of dimension 2×3 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 [2×3]
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 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 11×5 and TablaFlujo1 of dimension 2×3 are from the input flow, while tabla2 of dimension 11×5 and TablaFlow2 of dimension 2×3 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 [2×3]
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 simulink, loop, converge MATLAB Answers — New Questions