Algebraic Loop Error and does not linearization

Hello everyone, i'm working on (Control Tutorials for MATLAB and Simulink - Inverted Pendulum: Simulink Modeling (umich.edu)) Inverted pendulum modelling, however in 2021 version Matlab does not have "fcn" function so i tried to fix this problem by using matlab function. Now i can not have the graph and linearization cause i always have the same error which is Algebraic loop error with 'untitled1/Subsystem/MATLAB Function'. I'll try to explain what i have done
1) I created integrators and function blocks etc.
2) I used Mux for 4 functions as in the link given above.
3) I coded functions in those block.
4) When i connected them with muxes i followed muxed input numbers and my code values.
5)I cretaed subsystem. Add scope and trim it.
I need to linearization and see graphs but i can't.
function y = fcn(u)
m=0.01;
l=0.3;
y =m*(u(1)-l*u(2)^2*sin(u(3))+l*u(4)*cos(u(3)));
%This is for N value.
%Codes Errors:
Index expression out of bounds. Attempted to access element 2. The valid range is 1-1.
More information
Function 'Subsystem/MATLAB Function' (#55.53.54), line 4, column 20:
"2"
Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Errors occurred during parsing of MATLAB function 'untitled1/Subsystem/MATLAB Function'
Component:MATLAB Function | Category:Coder error
Simulink cannot determine sizes and/or types of the outputs for block 'untitled1/Subsystem/MATLAB Function' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
Component:MATLAB Function | Category:Coder error
Cannot solve algebraic loop involving 'untitled1/Subsystem/P' because it consists of blocks that cannot be assigned algebraic variables, such as blocks with discrete-valued outputs, blocks with non-double or complex outputs, Stateflow blocks, or nonvirtual subsystems. Consider breaking the algebraic loop. For example, add a delay or a memory block to the loop. To see more details about the loops use the command Simulink.BlockDiagram.getAlgebraicLoops(bdroot)
Component:Simulink | Category:Model error
Algebraic loop error with 'untitled1/Subsystem/MATLAB Function3'
Component:Simulink | Category:Model error
Algebraic loop error with 'untitled1/Subsystem/N'
Component:Simulink | Category:Model error
Algebraic loop error with 'untitled1/Subsystem/MATLAB Function'
Component:Simulink | Category:Model error
Algebraic loop error with 'untitled1/Subsystem/P'

5 个评论

I think not output value "xdot" "tdot" at initialization.
First try use block "Memory" at feedback
I tried but it doesn't work efficiently. From now on i'm working with Algrebraic Constraints.
If i'll find a better solution i'll update here.
Thanks
can you please add model or screenshot of updated model ?
I added algebraic constant to avoid loop error, it works but still i can not find those graphs.
I changed some constants properties, such as solver: Trust region.
Hello, did you manage to remove the algebraic loop?

请先登录,再进行评论。

回答(0 个)

类别

Community Treasure Hunt

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

Start Hunting!

Translated by