Got Questions? Get Answers.
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:
program formula

Subject: program formula

From: 1986

Date: 25 Aug, 2010 21:14:06

Message: 1 of 4

Hi everyone,
I need a help to program formula below:

x is the known vector
m = (k+1)/2
k = 5
M = length(x)

y = 100/(M-k+1) * sum(n=1:M-k+1)abs ( 1 - k*x(n+m-1) / sum(j=1:k)x(n+j-1) )

Thank you!

Subject: program formula

From: TideMan

Date: 26 Aug, 2010 01:03:02

Message: 2 of 4

On Aug 26, 9:14 am, "1986 " <milanaple...@gmail.com> wrote:
> Hi everyone,
> I need a help to program formula below:
>
> x is the known vector
> m = (k+1)/2
> k = 5
> M = length(x)
>
> y = 100/(M-k+1) * sum(n=1:M-k+1)abs ( 1 - k*x(n+m-1) / sum(j=1:k)x(n+j-1) )
>
> Thank you!

So, where have you got to in solving YOUR problem.
Show us the code you've got so far and we'll help debug it.
After all, it's only one line of code...............

Subject: program formula

From: Joseph

Date: 26 Aug, 2010 03:08:04

Message: 3 of 4

"1986 " <milanaplecas@gmail.com> wrote in message <i5412u$cs$1@fred.mathworks.com>...
> Hi everyone,
> I need a help to program formula below:
>
> x is the known vector
> m = (k+1)/2
> k = 5
> M = length(x)
>
> y = 100/(M-k+1) * sum(n=1:M-k+1)abs ( 1 - k*x(n+m-1) / sum(j=1:k)x(n+j-1) )
>
> Thank you!

Shoot, you're almost there. Remember your multiplication signs (*) though. I'm guessing you want to loop on j, so
for j = 1:M, (or whatever you want)
   your stuff here;
end;

Add semicolons at the end of each line (suppresses the output)

Subject: program formula

From: TideMan

Date: 26 Aug, 2010 03:26:49

Message: 4 of 4

On Aug 26, 3:08 pm, "Joseph " <don'twannapos...@nopers.com> wrote:
> "1986 " <milanaple...@gmail.com> wrote in message <i5412u$c...@fred.mathworks.com>...
> > Hi everyone,
> > I need a help to program formula below:
>
> > x is the known vector
> > m = (k+1)/2
> > k = 5
> > M = length(x)
>
> > y = 100/(M-k+1) * sum(n=1:M-k+1)abs ( 1 - k*x(n+m-1) / sum(j=1:k)x(n+j-1) )
>
> > Thank you!
>
> Shoot, you're almost there.  Remember your multiplication signs (*) though.  I'm guessing you want to loop on j, so
> for j = 1:M, (or whatever you want)
>    your stuff here;
> end;
>
> Add semicolons at the end of each line (suppresses the output)

No, don't loop.
Figure out the start and finish addresses for the two instances of x,
e.g., x(i1:i2), and simply sum them using the function sum.

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