Effacer les filtres
Effacer les filtres

Nested Structures using Custom Storage Classes RTW EC

1 vue (au cours des 30 derniers jours)
Andres le 6 Mai 2011
Hello, Could you tell me how can I configure a signal or an object in a simulink model to nest one custom class inside another without the tedious way of copying the tlc simulink file for signals and editing in the tlc lenguage? If there is no other way of doing it can anyone upload an example please.
I allready tryed to do it instead with busses but every time that i close the matlab program i lose the workspace (i know that i can restored, but that is not a portable solution for differents developers).
Thank you very much.

Réponses (4)

Jarrod Rivituso
Jarrod Rivituso le 6 Mai 2011
Can you be more specific as to how nested bus objects is limiting for you?
Most people I've encountered achieve nested structures via nested bus objects. To make the bus objects available when the model is loaded, it is common to
  1. Save the bus objects to a MAT-file. The Bus Editor allows you to easily do this.
  2. Use the model's Preload function to load the bus data when the model is loaded.
Are there other needs that you have that prevent this from working for you?

Andres le 9 Mai 2011
When I use the bus objects through the Bus Editor, I managed to define nested structures that later will be found in the "model_private.h" file. But I'm not able to locate in the generated code where does it use them. The point is that when I use the Custom Structure the variable is easy to find in the main.c and model.c files and I can track down how it is used. But when I use the buses I only find the name of the input signal but it does not use the structure.
I'm not sure if I did explain myself very well i'll try to make an example and attach it tomorrow.
  1 commentaire
Jarrod Rivituso
Jarrod Rivituso le 9 Mai 2011
Hmm... I wonder if you are using virtual busses? If you enable the option "Output as nonvirtual bus" in a Bus , does that change things? Nonvirtual bus signals should have their data type be that of the bus object typedef.

Connectez-vous pour commenter.

Andres le 7 Juin 2011
Ok, it took me a while to realease how to use them, but finally I deal with it.
A good example that I found from the matlab tutorials is: sldemo_lct_bus
Thank you very much for your quick answers

Andres le 15 Juin 2011
Hello again, I have another question on the same line.
Finally I managed to create nested structures with buses, the point is that when I use the Simulink.Bus.createMATLABStruct('Buses') command the resultant structure is like this:
Nested_Struct: [1x1 struct]
Number_Nested_Structures: 20
Param_A: 0
Param_B: 0
Insted of what I want which is:
Nested_Struct: [1x20 struct]
Number_Nested_Structures: 20
Param_A: 0
Param_B: 0
I do not need to use the Simulink.Bus.createMATLABStruct for anything, it is just to illustrate. What I want to do is access through a S-function block or an emedded matlab block to differents indexes of the Nested_Struct, depending on certain conditions.
Note: The number of nested structures change dynamically.
By the way I'm using Matlab 2010a.
Thank you very much.
PS: Which will it be the best block or way to load data in the model for the second structure?.


En savoir plus sur Simulink Coder dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by