# How do you do a sine transform in Matlab?

12 views (last 30 days)
L'O.G. on 19 Dec 2022
Commented: Paul on 20 Dec 2022
The sine transform is defined as
How do you do a sine transform and its inverse? The functions dst and idst are not recommended for some reason.

Star Strider on 19 Dec 2022
In general, a Fourier transform is defined as:
where:
and its inverse:
since apparently ξ is in Hz (or at least not already in radian measure). (The negative sign can be applied either to the forward or inverse transform, so long as the convention is maintained between them.)
So the inverse transform would likely be the negative of the original transform. There are several ways to calculate the integral, among them int and integral. (I doubt that trapz or cumtrapz would be appropriate here, however I am listing it to be complete.)
.
##### 2 CommentsShowHide 1 older comment
Star Strider on 19 Dec 2022
The integral produces a result that is a function of frequency, so define the frequency to define the funciton at that frequency —
syms f(t) xi
sympref('AbbreviateOutput',false);
f(t) = 1/2;
F(xi) = int(f*exp(1j*xi*t), t, -Inf, Inf)
F(xi) =
F(xi) = int(f*exp(1j*xi*t), t, -1, 1) % A More Tractible Expression
F(xi) =
F = simplify(F, 500)
F(xi) =
[n,d] = numden(F) % Calcuate Derivatives
n(xi) =
d(xi) =
ξ
dn = diff(n)
dn(xi) =
dd = diff(d)
dd(xi) =
1
figure
fplot(F, [-1 1]*15)
grid
title('Transform plotted as a function of frequency')
xlabel('Frequency')
ylabel('Magnitude')
The result in this instance is a sinc function. Not all functions will have analytic integrals, so in that event, it would be necessary to do numerical integration. (The value of this function at the origin is , however by L'Hospital’s rule, is , so finite.)
.

Bora Eryilmaz on 19 Dec 2022
Edited: Bora Eryilmaz on 19 Dec 2022
According to Wikipedia, versions of it can be computed using the discrete cosine transform: "A DST-III or DST-IV can be computed from a DCT-III or DCT-IV (see discrete cosine transform), respectively, by reversing the order of the inputs and flipping the sign of every other output, and vice versa for DST-II from DCT-II. In this way it follows that types II–IV of the DST require exactly the same number of arithmetic operations (additions and multiplications) as the corresponding DCT types."
Signal Processing Toolbox has the dct command: https://www.mathworks.com/help/signal/ref/dct.html

Paul on 20 Dec 2022
It appears that the sine transform can be computed from the Fourier transform.
Example with a simple function
syms t w xi real
f(t) = exp(-t)*heaviside(t);
Fourier transform of f(t)
F(xi) = subs(fourier(f(t),t,w),w,2*sym(pi)*xi)
F(xi) =
The sine transform is then
S(xi) = simplify(-F(xi) + F(-xi))/2i
S(xi) =
Compare to the sine transform computed from the defining integral
S(xi) = int(f(t)*sin(2*sym(pi)*xi*t),t,-inf,inf)
S(xi) =
##### 2 CommentsShowHide 1 older comment
Paul on 20 Dec 2022
But F(xi) is not the same as S(xi) in the example. Perhaps I don't understand the question ...

### Categories

Find more on Time-Frequency Analysis in Help Center and File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by