MATLAB Answers

## How can I measure the average of a signal at specified time points?

Asked by Simon Kalita-de Croft

### Simon Kalita-de Croft (view profile)

on 19 Jul 2019
Latest activity Commented on by Star Strider

### Star Strider (view profile)

on 19 Jul 2019
Accepted Answer by Star Strider

### Star Strider (view profile)

Hello
I'm sure this is a simple fix, but how can I measure the average of a signal at specified x points?
E.g. I want to measure the mean at 0 - 0.2 in the below exampe, and then again at 0.5-0.7
What code should I use please?
Thanks

#### 0 Comments

Sign in to comment.

## 1 Answer

### Star Strider (view profile)

Answer by Star Strider

### Star Strider (view profile)

on 19 Jul 2019
Accepted Answer

Try this:
t = ...; % Time Vector
s = ...; % Signal Vector
t1 = t <= 0.2;
t2 = (t >= 0.5) & (t <= 0.7);
s1 = mean(s(t1));
s2 = mean(s(t2));

#### 3 Comments

Simon Kalita-de Croft

### Simon Kalita-de Croft (view profile)

on 19 Jul 2019
Hi Star
I am truly new to this.
Could you please explain what this means?
t = ...; % Time Vector
s = ...;
Thanks
S
Simon Kalita-de Croft

### Simon Kalita-de Croft (view profile)

on 19 Jul 2019
Actually I got it.
Thank you very much Star!
S
Star Strider

### Star Strider (view profile)

on 19 Jul 2019
As always, my pleasure!

Sign in to comment.