# Wavelets, sample rate, and replicating Matlab's default call

**URL:** <https://discourse.julialang.org/t/wavelets-sample-rate-and-replicating-matlabs-default-call/136875>\
**Category:** New to Julia\
**Tags:** wavelets\
**Created:** [April 25, 2026, 8:11am UTC](https://discourse.julialang.org/t/wavelets-sample-rate-and-replicating-matlabs-default-call/136875 "2026-04-25T08:11:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahmah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mahmah/32/214326_2.png) [@mahmah](https://discourse.julialang.org/u/mahmah)\
**Post date:** [April 25, 2026, 8:11am UTC](https://discourse.julialang.org/t/wavelets-sample-rate-and-replicating-matlabs-default-call/136875/1 "2026-04-25T08:11:05Z")

</div>

Hi,

I’m trying to get the same output as with a default `cwt(x,fs)` Matlab function call, where x is a signal and fs its sample rate. Could anyone help me? Here’s what I have done so far, but I don’t know how to include sample rate here for instance:

```julia-auto
using ContinuousWavelets, Wavelets
function getcwt(d)
    n = length(d)
    c = wavelet(Morlet())
    freqs = getMeanFreq(computeWavelets(n, c)[1])
    a = cwt(d,c)
    return(a,freqs)
end

```

Any help would be greatly appreciated! 🙂

---

<div class="post-metadata">

**Author:** ![Boris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/boris/32/3306_2.png) [@Boris](https://discourse.julialang.org/u/Boris)\
**Post date:** [April 25, 2026, 12:24pm UTC](https://discourse.julialang.org/t/wavelets-sample-rate-and-replicating-matlabs-default-call/136875/2 "2026-04-25T12:24:01Z")

</div>

typing `help cwt` in my Matlab 2023b tells me there is no such default function.

```matlab
>> help cwt
--- cwt not found. Showing help for cat instead. ---
...

```

We can help you if you include a MWE and the matlab function that you want to translate. Make sure it is not from some proprietary toolbox (i.e. make sure you are allowed to share it)

---

<div class="post-metadata">

**Author:** ![mahmah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mahmah/32/214326_2.png) [@mahmah](https://discourse.julialang.org/u/mahmah)\
**Post date:** [April 25, 2026, 12:27pm UTC](https://discourse.julialang.org/t/wavelets-sample-rate-and-replicating-matlabs-default-call/136875/3 "2026-04-25T12:27:48Z")

</div>

Hi Boris,

maybe you didn’t add add the wavelet toolbox when you installed Matlab or didn’t have the license for it?

[https://www.mathworks.com/products/wavelet.html](https://www.mathworks.com/products/wavelet.html)

Here’s the function doc btw: [https://www.mathworks.com/help/wavelet/ref/cwt.html](https://www.mathworks.com/help/wavelet/ref/cwt.html)

---

<div class="post-metadata">

**Author:** ![mahmah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mahmah/32/214326_2.png) [@mahmah](https://discourse.julialang.org/u/mahmah)\
**Post date:** [April 25, 2026, 12:36pm UTC](https://discourse.julialang.org/t/wavelets-sample-rate-and-replicating-matlabs-default-call/136875/4 "2026-04-25T12:36:36Z")

</div>

Alternatively, I’m trying to have a wavelet transform that has very high frequency resolution for low frequencies. I’m interested in anything happening between 0.5 and 10 hz, but I don’t seem to get that region well represented with the function above (or maybe I’m doing something wrong?)

---

<div class="post-metadata">

**Author:** ![Boris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/boris/32/3306_2.png) [@Boris](https://discourse.julialang.org/u/Boris)\
**Post date:** [April 25, 2026, 1:22pm UTC](https://discourse.julialang.org/t/wavelets-sample-rate-and-replicating-matlabs-default-call/136875/5 "2026-04-25T13:22:10Z")

</div>

Yes, I do not have it, because I didn’t buy it.

Matlab’s toolboxes are not “default” functions, they are commercial products that Matlab is selling. People using the academic license are sometimes unaware of that because most universities get the academic discount and have all toolboxes available.

That is why I asked for the code, because one cannot translate a function that doesn’t see/have. But if it is a licensed product it is not OK to share I guess.

Are you trying to translate it to learn Julia or do you need this function in Julia to do some further analysis? If it is the latter, there are several packages that give you wavelets and Morse’s wavelet. Have a look at `GeneralizedMorseWavelets.jl` or `JuliaDSP`.

Offotpic, but, I don’t know about the wavelet toolbox per se, but for the econometrics toolbox I can say that there is not one function there that is fast, so if you need performance critical code, consider writing your own functions in matlab.

---

<div class="post-metadata">

**Author:** ![mahmah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mahmah/32/214326_2.png) [@mahmah](https://discourse.julialang.org/u/mahmah)\
**Post date:** [April 25, 2026, 1:43pm UTC](https://discourse.julialang.org/t/wavelets-sample-rate-and-replicating-matlabs-default-call/136875/6 "2026-04-25T13:43:10Z")

</div>

I’m trying to compute cwt in Julia in such a way that low frequency components are well represented, as mentioned in my message above 🙂

---

<div class="post-metadata">

**Author:** ![Boris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/boris/32/3306_2.png) [@Boris](https://discourse.julialang.org/u/Boris)\
**Post date:** [April 25, 2026, 1:51pm UTC](https://discourse.julialang.org/t/wavelets-sample-rate-and-replicating-matlabs-default-call/136875/7 "2026-04-25T13:51:18Z")

</div>

> [@Boris](#):
>
> `GeneralizedMorseWavelets`

And did you look in the packages that I mentioned?

---

<div class="post-metadata">

**Author:** ![mahmah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mahmah/32/214326_2.png) [@mahmah](https://discourse.julialang.org/u/mahmah)\
**Post date:** [April 25, 2026, 4:05pm UTC](https://discourse.julialang.org/t/wavelets-sample-rate-and-replicating-matlabs-default-call/136875/8 "2026-04-25T16:05:45Z")

</div>

Julia DSP is not a package, but it does have Wavelets.jl which ContinuousWavelets.jl is based on. GeneralizedMorseWavelets.jl could be more documented IMHO, but when following the example in the documentation it yields a visualisation that makes sense. If anyone knows how to get a complex CWT (not a real one) using GeneralizedMorseWavelets please let me know. 🙂

---

<div class="post-metadata">

**Author:** ![Marc.Cox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marc.cox/32/7514_2.png) [@Marc.Cox](https://discourse.julialang.org/u/Marc.Cox)\
**Post date:** [April 25, 2026, 6:10pm UTC](https://discourse.julialang.org/t/wavelets-sample-rate-and-replicating-matlabs-default-call/136875/9 "2026-04-25T18:10:45Z")

</div>

Hi @mahmah took a look into your question about complex wavelets sample rate

> " .. where x is a signal and fs its sample rate. \> Could anyone help me? Here’s what I have done so far, but I don’t know how to include sample rate here for instance:"

## FILE: /.julia/packages/NeuroAnalyzer/r2XpB/docs/src/index.md

```julia-auto
NeuroAnalyzer.cmax(x::Vector{<:Complex})
NeuroAnalyzer.cmin(x::Vector{<:Complex})

```

## Adding NOTE Regarding Julia Wavelet Sample Rate appears to be fs as per `fs::Int64: sampling rate`

```julia-auto
NeuroAnalyzer.generate_morlet(fs::Int64, f::Real, t::Real=1; ncyc::Int64=5, complex::Bool=false)
NeuroAnalyzer.generate_morlet_fwhm(fs::Int64, f::Real, t::Real=1; h::Float64=0.25)

```

## Example Julia code in FILE: /.julia/packages/NeuroAnalyzer/r2XpB/benchmarks/na\_benchmarking.jl

```julia-auto
@time fconv(e10, kernel=generate_morlet(256, 1, 32, complex=true))
print(rpad("Filter: moving average", 36))
NeuroAnalyzer.filter_mavg(e10, k=2)

```

Example Julia code in FILE: /.julia/packages/NeuroAnalyzer/r2XpB/src/analyze/spectrogram.jl  
kernel = generate\_morlet(fs, sf[frq\_idx], 1, ncyc=ncyc[frq\_idx], complex=true)

`## RE Sample Rate - - `fs::Int64`: sampling rate`

> **[NeuroAnalyzer.jl/src/analyze/psd.jl at main](https://codeberg.org/AdamWysokinski/NeuroAnalyzer.jl/src/branch/main/src/analyze/psd.jl)**
>
> NeuroAnalyzer.jl - Julia toolbox for analyzing neurophysiological data

```julia-auto

p = zeros(length(f))
    @inbounds for frq_idx in 1:nfrq
		## Marc TIP Adding NOTE Regarding Sample Rate appears to be fs per `fs::Int64`: sampling rate
        kernel = generate_morlet(fs, f[frq_idx], 1, ncyc = ncyc[frq_idx], complex = true)
        w_conv = fconv(s .* w, kernel = kernel, norm = false)
        p[frq_idx] = median(abs2.(w_conv))
    end

```

Hope that helps you. And, I find wavelets interesting so please let me know  
what your Julia code snippet / MWE (Minimum Working Example) was finally.  
I’m also interested to know a bit more about  
what you want your wavelet application to accomplish?  
and why using Complex wavelets?

---

<div class="post-metadata">

**Author:** ![mahmah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mahmah/32/214326_2.png) [@mahmah](https://discourse.julialang.org/u/mahmah)\
**Post date:** [April 25, 2026, 8:02pm UTC](https://discourse.julialang.org/t/wavelets-sample-rate-and-replicating-matlabs-default-call/136875/10 "2026-04-25T20:02:15Z")

</div>

Thank you @Marc.Cox ! This looks promising, I’ll have a look; I just wanted to compute wavelet magnitudes. I could have also used e.g. STFT for this, but I prefer to specify wavelet over window parameters 🙂.
