# Convert float matrix to abstract float

**URL:** <https://discourse.julialang.org/t/convert-float-matrix-to-abstract-float/87599>\
**Category:** General Usage\
**Created:** [September 21, 2022, 7:01pm UTC](https://discourse.julialang.org/t/convert-float-matrix-to-abstract-float/87599 "2022-09-21T19:01:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JosieG](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josieg/32/36221_2.png) [@JosieG](https://discourse.julialang.org/u/JosieG)\
**Post date:** [September 21, 2022, 7:01pm UTC](https://discourse.julialang.org/t/convert-float-matrix-to-abstract-float/87599/1 "2022-09-21T19:01:31Z")

</div>

I have a 2\*85 float matrix. And I need to pass it to a function

```julia
function func(
    Y::Matrix{T},
)::Matrix{T} where {T<:AbstractFloat}

```

So I think I have to convert the matrix from float type to Abstractfloat. I have a code that

```julia
em = AbstractFloat.(matrix)

```

But it does not work. What is the correct way to do it?

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [September 21, 2022, 7:02pm UTC](https://discourse.julialang.org/t/convert-float-matrix-to-abstract-float/87599/2 "2022-09-21T19:02:49Z")

</div>

You don’t have to convert the matrix type.

---

<div class="post-metadata">

**Author:** ![JosieG](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josieg/32/36221_2.png) [@JosieG](https://discourse.julialang.org/u/JosieG)\
**Post date:** [September 21, 2022, 7:05pm UTC](https://discourse.julialang.org/t/convert-float-matrix-to-abstract-float/87599/4 "2022-09-21T19:05:14Z")

</div>

But when I passed it directly, I got the following error

```julia
no method matching func(::Matrix{Float64}, ..)
Closest candidates are:
  func(::Matrix{T}, ...) where T<:AbstractFloat at In[1]:90
  func(::AbstractMatrix, ...) at In[1]:81

```

---

<div class="post-metadata">

**Author:** ![JosieG](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josieg/32/36221_2.png) [@JosieG](https://discourse.julialang.org/u/JosieG)\
**Post date:** [September 21, 2022, 7:07pm UTC](https://discourse.julialang.org/t/convert-float-matrix-to-abstract-float/87599/5 "2022-09-21T19:07:37Z")

</div>

Problem solved. Thanks!
