Thread Subject: Catch the index!!

Subject: Catch the index!!

From: Cyrock User

Date: 1 Jul, 2008 12:21:03

Message: 1 of 4

In simulink, i would want a system to do this:

Example:

[0 0 0 0 0 1 0]
      |
      v
  ____________
  |Subsystem |
  |__________|
      |
      v
      6

A signal of width n is a vector of all 0 with one 1. I
want to get the get the index of the non_zero element for
later use in a multiswitch.

How can I do this?

Thanks

Subject: Catch the index!!

From: Devdatt Lad

Date: 1 Jul, 2008 12:53:37

Message: 2 of 4

Cyrock User wrote:
> In simulink, i would want a system to do this:
>
> Example:
>
> [0 0 0 0 0 1 0]
> |
> v
> ____________
> |Subsystem |
> |__________|
> |
> v
> 6
>
> A signal of width n is a vector of all 0 with one 1. I
> want to get the get the index of the non_zero element for
> later use in a multiswitch.
>
> How can I do this?

This is a good example of something that can be done easily with MATLAB
but is non-trivial with Simulink. The best thing to do is to use an
Embedded MATLAB Function block in your Simulink model as the "Subsystem"
above.

--
Devdatt Lad
The MathWorks, Inc.

Subject: Catch the index!!

From: Cyrock User

Date: 1 Jul, 2008 14:14:03

Message: 3 of 4

Devdatt Lad <Devdatt.Lad@mathworks.com> wrote in message
<g4d9ch$p4p$1@fred.mathworks.com>...
> Cyrock User wrote:
> > In simulink, i would want a system to do this:
> >
> > Example:
> >
> > [0 0 0 0 0 1 0]
> > |
> > v
> > ____________
> > |Subsystem |
> > |__________|
> > |
> > v
> > 6
> >
> > A signal of width n is a vector of all 0 with one 1. I
> > want to get the get the index of the non_zero element
for
> > later use in a multiswitch.
> >
> > How can I do this?
>
> This is a good example of something that can be done
easily with MATLAB
> but is non-trivial with Simulink. The best thing to do
is to use an
> Embedded MATLAB Function block in your Simulink model as
the "Subsystem"
> above.
>
> --
> Devdatt Lad
> The MathWorks, Inc.

Min/Max are supported in Embeded matlab...do I need a
special licence to compile it with RTW? (other than RTW)

Subject: Catch the index!!

From: riccardo

Date: 2 Jul, 2008 07:55:03

Message: 4 of 4

"Cyrock User" <razor4045@gmail.com> wrote in message
<g4de3b$k4l$1@fred.mathworks.com>...
> Devdatt Lad <Devdatt.Lad@mathworks.com> wrote in message
> <g4d9ch$p4p$1@fred.mathworks.com>...
> > Cyrock User wrote:
> > > In simulink, i would want a system to do this:
> > >
> > > Example:
> > >
> > > [0 0 0 0 0 1 0]
> > > |
> > > v
> > > ____________
> > > |Subsystem |
> > > |__________|
> > > |
> > > v
> > > 6
> > >
> > > A signal of width n is a vector of all 0 with one 1.
I
> > > want to get the get the index of the non_zero element
> for
> > > later use in a multiswitch.
> > >
> > > How can I do this?
> >
> > This is a good example of something that can be done
> easily with MATLAB
> > but is non-trivial with Simulink. The best thing to do
> is to use an
> > Embedded MATLAB Function block in your Simulink model
as
> the "Subsystem"
> > above.
> >
> > --
> > Devdatt Lad
> > The MathWorks, Inc.
>
> Min/Max are supported in Embeded matlab...do I need a
> special licence to compile it with RTW? (other than RTW)

Another option is to write a simple s-function block and
its companion TLC file. Guaranteed to work with
Simulink/RTW.

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com