Bus with sub buses with wrong type (bug ?)
Hello everyone!
Settings
I am facing a very strange issue. Here is my situation : I am creating a Simulink model that call a complex Matlab function. The function, name MD, is take a nested struct as an input, named config. The struct will be updated meaning adding fields (only on the first call), and updated value.
After some research, I have understood that the best way to solve my problem is to create a type ‘bus :configbus’, via
Simulink.Bus.createObject(config)
evalin(‘base’, ‘configbus = slBus1;’);
clear("slBus1")
Then, in Simulink I have my Matlab function block, linked to Data Store Read / write for interfacing the config input. This is for the setup.
Adding fields
To solve the fact that on the first call I am adding fields, I run once the function MD, before the simulation and creating the bus, to get all the correct field. I am open to better solution that this bit if you have any.
Errors encounter
However, when configuring the Data Store Memory with the Initial value I get the following error (error1):
Invalid setting in ‘path to Data Store Read’ for parameter ‘InitialValue’.
I am trying the following combination:
Inital Value : config
type : Bus:configBus.
(my function as the input define as the correct type and there is no issue there)
When I run my model I get the error (error2):
Error using Leia_main (line 47)
Expression ‘configBus’ for type of data ‘config’ did not evaluate to a valid type.
Caused by:
Error using Leia_main (line 47)
Invalid setting in ‘Guidance/If Action Subsystem2/If Action Subsystem1/New Planing/MATLAB Function’ for parameter ‘Datatype’
Error using Leia_main (line 47)
Error evaluating MATLAB Function parameter data
‘Datatype’ in its parent workspace.
Error using Leia_main (line 47)
Unrecognized function or variable ‘configBus’.
Error using Leia_main (line 47)
Variable ‘configBus’ does not exist.
Suggested Actions:
• Load a file into base workspace. – Fix
• Create a new variable. – Fix
Which is really wierd, since it seems that Matlab is confusing the type and the variable. But I have checked and everything seems to be declare as it should.
My investigation
When I look at my top bus definition it do not seems that field corresponding to subbuses are mapped properly. Even though the correct bus type exist.
Here is an example :
SK_requirement is supposed to be of type bus: SK_requirement but is of type SK_requirement which I don’t know what type it points to.
And if I set it correctly I get :
Is there any reason why this is behaving like this ? I would expect that the configbus declartion to be correctly typed. (I will try to manually set the good type and see if there is any improvement). My naive guess is that it might solve error1, but not sure.
Questions
1) Is there a better way to create the top level bus ? Or is it just a bug ?
2) Do you have any idea for error1 ?
3) Do you have any idea for solutioning error2 ?
Information
Runing matlab25a without the last update. Using MacOS with Apple chip.
Thank you in advance for your insights.Hello everyone!
Settings
I am facing a very strange issue. Here is my situation : I am creating a Simulink model that call a complex Matlab function. The function, name MD, is take a nested struct as an input, named config. The struct will be updated meaning adding fields (only on the first call), and updated value.
After some research, I have understood that the best way to solve my problem is to create a type ‘bus :configbus’, via
Simulink.Bus.createObject(config)
evalin(‘base’, ‘configbus = slBus1;’);
clear("slBus1")
Then, in Simulink I have my Matlab function block, linked to Data Store Read / write for interfacing the config input. This is for the setup.
Adding fields
To solve the fact that on the first call I am adding fields, I run once the function MD, before the simulation and creating the bus, to get all the correct field. I am open to better solution that this bit if you have any.
Errors encounter
However, when configuring the Data Store Memory with the Initial value I get the following error (error1):
Invalid setting in ‘path to Data Store Read’ for parameter ‘InitialValue’.
I am trying the following combination:
Inital Value : config
type : Bus:configBus.
(my function as the input define as the correct type and there is no issue there)
When I run my model I get the error (error2):
Error using Leia_main (line 47)
Expression ‘configBus’ for type of data ‘config’ did not evaluate to a valid type.
Caused by:
Error using Leia_main (line 47)
Invalid setting in ‘Guidance/If Action Subsystem2/If Action Subsystem1/New Planing/MATLAB Function’ for parameter ‘Datatype’
Error using Leia_main (line 47)
Error evaluating MATLAB Function parameter data
‘Datatype’ in its parent workspace.
Error using Leia_main (line 47)
Unrecognized function or variable ‘configBus’.
Error using Leia_main (line 47)
Variable ‘configBus’ does not exist.
Suggested Actions:
• Load a file into base workspace. – Fix
• Create a new variable. – Fix
Which is really wierd, since it seems that Matlab is confusing the type and the variable. But I have checked and everything seems to be declare as it should.
My investigation
When I look at my top bus definition it do not seems that field corresponding to subbuses are mapped properly. Even though the correct bus type exist.
Here is an example :
SK_requirement is supposed to be of type bus: SK_requirement but is of type SK_requirement which I don’t know what type it points to.
And if I set it correctly I get :
Is there any reason why this is behaving like this ? I would expect that the configbus declartion to be correctly typed. (I will try to manually set the good type and see if there is any improvement). My naive guess is that it might solve error1, but not sure.
Questions
1) Is there a better way to create the top level bus ? Or is it just a bug ?
2) Do you have any idea for error1 ?
3) Do you have any idea for solutioning error2 ?
Information
Runing matlab25a without the last update. Using MacOS with Apple chip.
Thank you in advance for your insights. Hello everyone!
Settings
I am facing a very strange issue. Here is my situation : I am creating a Simulink model that call a complex Matlab function. The function, name MD, is take a nested struct as an input, named config. The struct will be updated meaning adding fields (only on the first call), and updated value.
After some research, I have understood that the best way to solve my problem is to create a type ‘bus :configbus’, via
Simulink.Bus.createObject(config)
evalin(‘base’, ‘configbus = slBus1;’);
clear("slBus1")
Then, in Simulink I have my Matlab function block, linked to Data Store Read / write for interfacing the config input. This is for the setup.
Adding fields
To solve the fact that on the first call I am adding fields, I run once the function MD, before the simulation and creating the bus, to get all the correct field. I am open to better solution that this bit if you have any.
Errors encounter
However, when configuring the Data Store Memory with the Initial value I get the following error (error1):
Invalid setting in ‘path to Data Store Read’ for parameter ‘InitialValue’.
I am trying the following combination:
Inital Value : config
type : Bus:configBus.
(my function as the input define as the correct type and there is no issue there)
When I run my model I get the error (error2):
Error using Leia_main (line 47)
Expression ‘configBus’ for type of data ‘config’ did not evaluate to a valid type.
Caused by:
Error using Leia_main (line 47)
Invalid setting in ‘Guidance/If Action Subsystem2/If Action Subsystem1/New Planing/MATLAB Function’ for parameter ‘Datatype’
Error using Leia_main (line 47)
Error evaluating MATLAB Function parameter data
‘Datatype’ in its parent workspace.
Error using Leia_main (line 47)
Unrecognized function or variable ‘configBus’.
Error using Leia_main (line 47)
Variable ‘configBus’ does not exist.
Suggested Actions:
• Load a file into base workspace. – Fix
• Create a new variable. – Fix
Which is really wierd, since it seems that Matlab is confusing the type and the variable. But I have checked and everything seems to be declare as it should.
My investigation
When I look at my top bus definition it do not seems that field corresponding to subbuses are mapped properly. Even though the correct bus type exist.
Here is an example :
SK_requirement is supposed to be of type bus: SK_requirement but is of type SK_requirement which I don’t know what type it points to.
And if I set it correctly I get :
Is there any reason why this is behaving like this ? I would expect that the configbus declartion to be correctly typed. (I will try to manually set the good type and see if there is any improvement). My naive guess is that it might solve error1, but not sure.
Questions
1) Is there a better way to create the top level bus ? Or is it just a bug ?
2) Do you have any idea for error1 ?
3) Do you have any idea for solutioning error2 ?
Information
Runing matlab25a without the last update. Using MacOS with Apple chip.
Thank you in advance for your insights. simulink, bus, sub-bus, type, datastorememory, matlab function MATLAB Answers — New Questions