Thread Subject: How to define an array of input in s function builder?

Subject: How to define an array of input in s function builder?

From: Rohit

Date: 25 Nov, 2009 18:55:11

Message: 1 of 3

Hi
I am new to matlab and it will be great if you could help me out with this very small problem.
I have an array of input, say, x of length 5 and other normal scalar inputs.
How to define x inside s function builder? Like for other inputs (scalar), i define it as
static real_T a,b; (if a & b are other inputs). I am even facing problem using a for loop inside s function builder and may be that is because, i m defning x in a wrong manner.
Please go through this small code and suggest me somethng:

static real_T Ra,Ro ;
static real_T *hrr,i ;

Ta = u[0];
To = u[1];
for(i=1;i<4;i++)
{
 hrr[i] = u[1+i];
}

y[0] = hrr[2]*Ra*Ro;

Here, hrr is going as an array of input of length 3. Ra & Ro are other scalar inputs. Finally there is only one output (y[0])

The Errors i was getting while building the s functon builder
Error testing_wrapper.c: 58 operands of + have illegal types `pointer to double' and `double'
Error testing_wrapper.c: 58 type error: pointer expected
Error testing_wrapper.c: 58 operands of + have illegal types `pointer to const double' and `double'
Error testing_wrapper.c: 58 type error: pointer expected

Line 58 corresponds to static real_T *hrr,i ;
Its a very easy code. I just want to be familiar with s function builder. So please help me out.
Thanx

Subject: How to define an array of input in s function builder?

From: Rohit

Date: 25 Nov, 2009 19:12:19

Message: 2 of 3

"Rohit " <mascot12@gmail.com> wrote in message <hejuif$mqe$1@fred.mathworks.com>...
> Hi
> I am new to matlab and it will be great if you could help me out with this very small problem.
> I have an array of input, say, x of length 5 and other normal scalar inputs.
> How to define x inside s function builder? Like for other inputs (scalar), i define it as
> static real_T a,b; (if a & b are other inputs). I am even facing problem using a for loop inside s function builder and may be that is because, i m defning x in a wrong manner.
> Please go through this small code and suggest me somethng:
>
> static real_T Ra,Ro ;
> static real_T *hrr,i ;
>
> Ra = u[0];
> Ro = u[1];
> for(i=1;i<4;i++)
> {
> hrr[i] = u[1+i];
> }
>
> y[0] = hrr[2]*Ra*Ro;
>
> Here, hrr is going as an array of input of length 3. Ra & Ro are other scalar inputs. Finally there is only one output (y[0])
>
> The Errors i was getting while building the s functon builder
> Error testing_wrapper.c: 58 operands of + have illegal types `pointer to double' and `double'
> Error testing_wrapper.c: 58 type error: pointer expected
> Error testing_wrapper.c: 58 operands of + have illegal types `pointer to const double' and `double'
> Error testing_wrapper.c: 58 type error: pointer expected
>
> Line 58 corresponds to static real_T *hrr,i ;
> Its a very easy code. I just want to be familiar with s function builder. So please help me out.
> Thanx

Subject: How to define an array of input in s function builder?

From: Rohit

Date: 26 Nov, 2009 03:50:20

Message: 3 of 3

"Rohit " <mascot12@gmail.com> wrote in message <hejvij$ol6$1@fred.mathworks.com>...
> "Rohit " <mascot12@gmail.com> wrote in message <hejuif$mqe$1@fred.mathworks.com>...
> > Hi
> > I am new to matlab and it will be great if you could help me out with this very small problem.
> > I have an array of input, say, x of length 5 and other normal scalar inputs.
> > How to define x inside s function builder? Like for other inputs (scalar), i define it as
> > static real_T a,b; (if a & b are other inputs). I am even facing problem using a for loop inside s function builder and may be that is because, i m defning x in a wrong manner.
> > Please go through this small code and suggest me somethng:
> >
> > static real_T Ra,Ro ;
> > static real_T *hrr,i ;
> >
> > Ra = u[0];
> > Ro = u[1];
> > for(i=1;i<4;i++)
> > {
> > hrr[i] = u[1+i];
> > }
> >
> > y[0] = hrr[2]*Ra*Ro;
> >
> > Here, hrr is going as an array of input of length 3. Ra & Ro are other scalar inputs. Finally there is only one output (y[0])
> >
> > The Errors i was getting while building the s functon builder
> > Error testing_wrapper.c: 58 operands of + have illegal types `pointer to double' and `double'
> > Error testing_wrapper.c: 58 type error: pointer expected
> > Error testing_wrapper.c: 58 operands of + have illegal types `pointer to const double' and `double'
> > Error testing_wrapper.c: 58 type error: pointer expected
> >
> > Line 58 corresponds to static real_T *hrr,i ;
> > Its a very easy code. I just want to be familiar with s function builder. So please help me out.
> > Thanx

Please help me out with this problem. I need to work on a big code and without this basic knowledge i cannot proceed.

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
array of input Rohit 25 Nov, 2009 13:59:06
rssFeed for this Thread

Contact us at files@mathworks.com