Clear Filters
Clear Filters

Generating and plotting result of upfirdn

3 views (last 30 days)
musedpony
musedpony on 24 Jun 2017
Commented: Walter Roberson on 25 Jun 2017
I'm trying to pass rectangular pulses into a raised cosine filter to smooth the edges, then plot this result against time. It seems like upfirdn(xin,h,p,q) only accepts double-precision input for xin. However, I've defined my xin in terms of a sum of shifted rectangular pulses that encode user-input binary data – I'm not sure how to make the conversion to double-precision such that upfirdn will filter the square pulses and produce an output with the same information content but with smoothed edges (lower bandwidth). The final plot should look pretty much the same as the plot of m(t), but 'smoothed' out and like a sum of sinusoids.
I've attached the code for reference. Thanks for the help!

Answers (1)

Walter Roberson
Walter Roberson on 24 Jun 2017
Edited: Walter Roberson on 25 Jun 2017
You have
m = 0; % define the function m(t)
and then you add pulses to m. You are initializing m as double precision, so your final sum will be double precision. Therefore you already have double precision values for the first input to the raised cosine filter.
  3 Comments
Walter Roberson
Walter Roberson on 25 Jun 2017
It was a typo, sorry: you initialized to double precision so the sum will be double precision.
Walter Roberson
Walter Roberson on 25 Jun 2017
I missed that you are passing sym t to rectangularPulse, so your m is going to be symbolic. You need to substitute a definite vector of times for t in your m before you call upfirdn. This is a problem because you have not defined your bit-time.
For example,
times = 0:N*T+T;
mm = double(subs(m,t,times));
x = upfirdn(mm, h, sps);
This will not be symbolic, so you will have difficulty plotting it with fplot. You will instead need to do something like
tvec = (0:length(x)-1)/sps;
plot(tvec, x);
However, I am not certain that this time vector is appropriate. I figure that length(x) is (length(mm)-1)*sps + length(h) but it is not obvious how to relate that to times, so I just assume that the samples are 1/sps apart

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!