How to input two values as one value

Hi, I'm wondering how two different values can be combined into one individual value. For example, I have a signal Y with 10000 samples, with 100 samples equalling to 1 second. If I were trying to plot Y in terms of seconds, that is rather easy to do by using a code
samples = length(Y);
fs = 100;
time = 0:1/fs:samples/fs-1/fs;
and then simply plotting plot(time, Y). However, If I wanted to do something like plotting the power spectrum density of the signal using pwelch but only for the section between 20 and 40 seconds, how would I code this? Thanks

 Accepted Answer

samples = length(Y);
fs = 100;
time = 0:1/fs:samples/fs-1/fs;
iwant = Y(time>=20 & time<=40)) %<-- this pciks Y for time between 20 and 40 seconds

2 Comments

And in this case, to take the pwelch, you would simply define pwelch(iwant), correct?

Sign in to comment.

More Answers (0)

Categories

Find more on Signal Processing Toolbox in Help Center and File Exchange

Products

Release

R2021a

Asked:

on 27 Apr 2023

Commented:

on 27 Apr 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!