# How to use the array as the argument for curve-fit?

**URL:** <https://discourse.julialang.org/t/how-to-use-the-array-as-the-argument-for-curve-fit/99802>\
**Category:** General Usage\
**Tags:** lsqfit\
**Created:** [June 3, 2023, 7:51am UTC](https://discourse.julialang.org/t/how-to-use-the-array-as-the-argument-for-curve-fit/99802 "2023-06-03T07:51:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![manu\_han](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manu_han/32/47520_2.png) [@manu\_han](https://discourse.julialang.org/u/manu_han)\
**Post date:** [June 3, 2023, 7:51am UTC](https://discourse.julialang.org/t/how-to-use-the-array-as-the-argument-for-curve-fit/99802/1 "2023-06-03T07:51:57Z")

</div>

I wanna using curve-fit with an independent variable constituted by 4 float64 elements (Vector{Array{Float64,3} with 4 elements}.  
However, It didn’t work and give the message as follows:  
MethodError: no method matching isinf(::Array{Float64, 3})

The toy example is here:

```julia
A=rand(150,27,55) #element1
B=rand(1,1,55) #element2
C=rand(150,27) #element3
D=rand(200,3,55) #element4
IV=[A, B, C, D] #independent variable

function LSQFIT(para, IP)
                T=IP; #initial point
                A=IV[1]; B=IV[2]; C=IV[3]; Fv_D=IV[4];
end

fit=curve_fit(LSQFIT, IV, DV, IP)

```

Is there a way to use variable ‘IV’ as the argument of curve-fitting?

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 3, 2023, 6:30pm UTC](https://discourse.julialang.org/t/how-to-use-the-array-as-the-argument-for-curve-fit/99802/2 "2023-06-03T18:30:49Z")

</div>

Where does the function curve\_fit come from?

---

<div class="post-metadata">

**Author:** ![manu\_han](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/manu_han/32/47520_2.png) [@manu\_han](https://discourse.julialang.org/u/manu_han)\
**Post date:** [June 4, 2023, 1:04pm UTC](https://discourse.julialang.org/t/how-to-use-the-array-as-the-argument-for-curve-fit/99802/3 "2023-06-04T13:04:54Z")

</div>

I cited [GitHub - JuliaNLSolvers/LsqFit.jl: Simple curve fitting in Julia](https://github.com/JuliaNLSolvers/LsqFit.jl). DV (dependent variable), IP (initial point), and return(output of the function) are omitted from the toy example because it seems not to relate to the argument type.

I’m not sure if I understood your question correctly.

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 4, 2023, 4:29pm UTC](https://discourse.julialang.org/t/how-to-use-the-array-as-the-argument-for-curve-fit/99802/4 "2023-06-04T16:29:22Z")

</div>

Actually it would be better to include all of these variables, and package imports, so that people who try to help you can reproduce your errors 🙂
