Error in function with circular buffer for simulink.

5 visualizaciones (últimos 30 días)
Manmohan Butola
Manmohan Butola el 3 de Ag. de 2021
Editada: Vinay el 21 de Nov. de 2024 a las 6:47
Hello.
I have created a simulink function which takes two inputs and put them in separate circular bufffers circBuff_In_1 and circBuff_In_2. This function calls another function 'Linearizer.m' which is adding the first elements of cicular buffers. But there is an error stating 'An error occured while running the simulation and simulation was terminated caused by : circBuff_In_1 ' Kindly help me rectifying this error. Model and function code attached herewith.
Thanks

Respuestas (1)

Vinay
Vinay el 21 de Nov. de 2024 a las 6:46
Editada: Vinay el 21 de Nov. de 2024 a las 6:47
The MATLAB function in the simulink model creates two circular buffers named as 'circBuff_In' and 'circBuff_PA' to store the input signal.But the linearizeer function is using different variable names which is causing the issue.
The MATLAB function code can be updated to use the correct variable names as given below
function Output = lin_Fun(In_1,In_2)
coder.extrinsic('Linearizer');
Output= 0;
persistent circBuff_In;
persistent circBuff_PA;
if isempty(circBuff_In)
circBuff_In = zeros(1,10);
end
if isempty(circBuff_PA)
circBuff_PA = zeros(1,10);
end
global N;
global n;
Output = circBuff_In(1)+circBuff_PA(1);
circBuff_In = [In_1 circBuff_In(1:end-1)];
circBuff_PA = [In_2 circBuff_PA(1:end-1)];
end
The figure below shows the result of the spectrum analyzer
Hope this would resolve the issue!

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by