3 ms·
IMO, sinpi(x)=sin(pi*x) is a better function because it does much better here. the regular trig functions are approximately 20% slower for most implementations
by adgjlsfhk1 5y ago
IMO, sinpi(x)=sin(pi*x) is a better function because it does much better here. the regular trig functions are approximately 20% slower for most implementations in order to accurately reduce mod 2pi, while reducing mod 2 is pretty much trivial.
- willis936 5y agoI think the real solution I should have adopted is incrementing t like this: t = mod(t + ts, 1 / f) Since I'm just sending a static frequency the range of time never needs to be beyond one period. However, using a double here is far from the critical path in increasing performance and it all runs fast enough anyway.
- willis936 5y agoAlso, thanks. I had not heard of this function before, but apparently it was added to MATLAB in 2018.