Trying to plot my bandpass filtered signal in a time series, but I need to divide the x values by 2000 (the sampling rate) to get it to plot in seconds instead of samples/seconds
1 view (last 30 days)
Show older comments
Bandpass_channel2 = filtfilt(bandpass_filter, Double_chan2); % this is the filtered signal used
figure, plot(Bandpass_channel2) %% the plot but the x values are 10^5 (need to divide by 2k)
bch2 = Bandpass_channel2 / 2000; % this caused the y values to be divided by 2k not the x :(
TS = timeseries(bch2);
figure, plot(TS) % just added "time as the x-axis lable
0 Comments
Answers (1)
Mathieu NOE
on 21 Apr 2021
hello Rachel
in most of my matlab code, I have to get the samples amount and define explicitly the time vector like this
samples = length(data);
Fs = 1000; % example
dt = 1/Fs;
t = (0:samples-1)*dt;
plot(t,data) ; % time axis in seconds
so that it's pretty obvious you will plot the right time axis this way
0 Comments
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!