Thread Subject:
Signal Name through S funcion

Subject: Signal Name through S funcion

From: Jagmohan singh

Date: 14 Jun, 2012 06:01:09

Message: 1 of 5

Hi,
I am looking for a way so that I can assign names to the output signal in s-function itself. Also I need to access the input signal names inside s-function. Is it possible?

My problem is I am trying to build a generic simulink block. I want to pass the information of number of output ports, number of input ports as well as their names through mask parameters. Inside s-function I need to do the some calculation based on the names of the input signals and I want to assign the names to the output signals.


Thanks in advance,
Jagmohan

Subject: Signal Name through S funcion

From: Phil Goddard

Date: 14 Jun, 2012 14:22:06

Message: 2 of 5

You could do this using get_param and set_param (easier in an m-code S-function, but also do-able in a cmex S-Function through calling mexCallMatlab), but it would be unusual.

What if the block isn't connected, i.e. there is no signal to get a name from?
or the outputs are not connected so again no signal to name?

Usually you'd do this sort of thing as part of the mask initialization, and name underlying Inport and Outport blocks, having those names appear on the mask.

Phil.

Subject: Signal Name through S funcion

From: Jagmohan singh

Date: 14 Jun, 2012 14:54:06

Message: 3 of 5

"Phil Goddard" <phil@goddardconsulting.ca> wrote in message <jrcs2d$etf$1@newscl01ah.mathworks.com>...
> You could do this using get_param and set_param (easier in an m-code S-function, but also do-able in a cmex S-Function through calling mexCallMatlab), but it would be unusual.
>
> What if the block isn't connected, i.e. there is no signal to get a name from?
> or the outputs are not connected so again no signal to name?
>
> Usually you'd do this sort of thing as part of the mask initialization, and name underlying Inport and Outport blocks, having those names appear on the mask.
>
> Phil.

Thanks Phil,

Is it really possivle to name signals through set_param?
I want to create a generic simulink block which will do some calculation and will assign the results to ouput signals. These results will be fed to another block where a bus selector selects the signal by name of the signal. If I can assign thr name to the signal inside sfunc itself so that I can avoid any possible mistake from the user in naming signal. As this is all about making a model using this generic block, I wil have names of the signal in a .m file that will be used if nothing is assigned.

Subject: Signal Name through S funcion

From: Phil Goddard

Date: 17 Jun, 2012 04:14:08

Message: 4 of 5


> Is it really possivle to name signals through set_param?

Sure.
Consider a model that just has a Constant feeding into a Scope.
Select the constant block to make it the currently selected block, then
>> ph = get_param(gcb,'PortHandles');
>> set(ph.Outport,'Name','NewSigName');

The above generalizes to any block.

Phil.

Subject: Signal Name through S funcion

From: Jagmohan singh

Date: 18 Jun, 2012 12:38:07

Message: 5 of 5

"Phil Goddard" <phil@goddardconsulting.ca> wrote in message <jrjlig$qqu$1@newscl01ah.mathworks.com>...
>
> > Is it really possivle to name signals through set_param?
>
> Sure.
> Consider a model that just has a Constant feeding into a Scope.
> Select the constant block to make it the currently selected block, then
> >> ph = get_param(gcb,'PortHandles');
> >> set(ph.Outport,'Name','NewSigName');
>
> The above generalizes to any block.
>
> Phil.


Thanks Phil...

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
simulink Phil Goddard 14 Jun, 2012 10:24:08
sfunction Jagmohan singh 14 Jun, 2012 02:04:12
signal names Jagmohan singh 14 Jun, 2012 02:04:12
rssFeed for this Thread

Contact us