Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Get Bus Information from BusCreator/-Selector

Subject: Get Bus Information from BusCreator/-Selector

From: Jens Schröter

Date: 9 Sep, 2010 07:22:05

Message: 1 of 5

Hi,

I work with Matlab R2007b and I am writing a m-File, which generates a Simulink Model.

My problem is to get useable information from the BusCreator or the Inputs of the BusSelector about the Bushierarchy/Busstructur. The code should work for a bus with random levels. I need the information for including them in a GUI where the different buses and signals are listed like in the GUI of the BusSelector in the field "Signals in the Bus".

If the bus has got only 1 level the following code works:


function listbox1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

InputSignale = get_param([gcb '/Bus Selector'],'InputSignals');

SignalAnzahlMatrix = size(InputSignale);
SignalAnzahl=SignalAnzahlMatrix(1,1);

SignalListe='';

for (i=1:SignalAnzahl)
    SignalListe=[SignalListe ; InputSignale(i)];
end

set(hObject,'String',SignalListe);



If the Bus has got 2 or more levels the following message will be displayed:

??? Error using ==> set
Cell array of strings may only contain string and numeric matrices.

Error in ==> BusSelector_Subsystem>listbox1_CreateFcn at 109
set(hObject,'String',SignalListe);


Does somebody know a solution? Thank you for your help!

Best regards,

Jens

Subject: Get Bus Information from BusCreator/-Selector

From: Jens

Date: 10 Sep, 2010 09:10:18

Message: 2 of 5

I try to specifiy my question:

Which commands are available for getting information about the signals and buses included in a bus?

Subject: Get Bus Information from BusCreator/-Selector

From: Thomas Vanaret

Date: 10 Sep, 2010 12:46:05

Message: 3 of 5

"Jens " <JSch2@web.de> wrote in message <i6cslq$feg$1@fred.mathworks.com>...
> I try to specifiy my question:
>
> Which commands are available for getting information about the signals and buses included in a bus?

You can have a look to this old thread dealing with a similar problem : "Access bus signal names in S-function"
http://www.mathworks.fr/matlabcentral/newsreader/view_thread/157372

You can also use the "unofficial" parameter "BusStruct" for Bus Creator & Mux blocks.

Subject: Get Bus Information from BusCreator/-Selector

From: Fangjun Jiang

Date: 10 Sep, 2010 13:52:05

Message: 4 of 5

I am not aware of any built-in command, however you can write your own or try to search in Matlab Central.

If you look at the "InputSignals" property of a BusSelector block, it is a cell array. Its contents are either char array or cell array depending on the input bus hierarchy. You can write a recursive function to get all the signals in the bus. I've written one but unfortunately I can't share it.

"Thomas Vanaret" <firstname.lastname@safran-engineering.com> wrote in message <i6d9ad$pee$1@fred.mathworks.com>...
> "Jens " <JSch2@web.de> wrote in message <i6cslq$feg$1@fred.mathworks.com>...
> > I try to specifiy my question:
> >
> > Which commands are available for getting information about the signals and buses included in a bus?
>
> You can have a look to this old thread dealing with a similar problem : "Access bus signal names in S-function"
> http://www.mathworks.fr/matlabcentral/newsreader/view_thread/157372
>
> You can also use the "unofficial" parameter "BusStruct" for Bus Creator & Mux blocks.

Subject: Get Bus Information from BusCreator/-Selector

From: Jens

Date: 14 Sep, 2010 08:59:08

Message: 5 of 5

Thank you all for your help.

But in the end I found the solution in the m-File "treeview.m".....



This function creates a listbox with a tree structure and manages
expanding and collapsing of the nodes in the tree via its
callback. The currently supported forms of data that can be passed
to the treeview are :
1) A structure, where the field names represent the nodes of the
    tree.
 2) A cell array. If an element of the cell array is a string, it
represents a node with no children. If the element is a cell
array, the first element of that cell array represents the name of
the node and the second element contains the children of that node.

TREEVIEW('Create', FIGURE, DATA) creates a listbox uicontrol in
the specified figure and returns a handle to the uicontrol.


...and it works!!

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us