Closed crazy734 closed 3 years ago
What file are you referring to with line 757
? And can you provide an example that currently does not work?
@kabdelhak i think this is not related to openmodelica code generation for linearization
, it is related to OMMatlab.m
stand alone linearization
API
Thank you @arun3688 . It is an OMMatlab.m linearization
API within the file itself @kabdelhak . It needs to changed as I mentioned above. However, since you asked for an example of it not working, I'll give you one below.
This only happens because matrix_name
in the second iteration of the loop is empty and the isempty
function directly does not work on empty struct
. On the second iteration, fieldnames
of the struct
are empty and not the struct
itself. Therefore this edit is required.
@crazy734 , can you make a PR with the changes you made ?, i can push it
As a side note, shouldn't we avoid to have code to do this in two different places? Or do I miss something?
@casella this is a stand alone package, the current code generation has nothing to do with this
OK, so I guess we just need to be careful to keep them in synch
Hey,
There's a minor issue in the linearization function that I may have noticed in line 757. The isempty function does not work if the fields of the struct are empty, i.e. even if it is a 1X1 struct with no fieldnames as well, the ~isempty(matrix_name) returns a 1.
if(~isempty(matrix_name)) fields=fieldnames(matrix_name);
I also found the solution by changing it to
if(~isempty(fieldnames(matrix_name))) fields=fieldnames(matrix_name);