Plotting a surface in Julia

Viewed 106

I'd like to plot a surface in Julia, but using this syntax:

f(x)=x[1]-x[2]

not

f(x,y)=x-y

Could you help me do that?

1 Answers

In this case the simplest approach is to use a wrapper anonymous function:

(x...) -> f(x)

that you can pass to the plotting function instead of your original function.

Now you have:

julia> f(x)=x[1]-x[2]
f (generic function with 1 method)

julia> ((x...) -> f(x))(100, 5)
95
Related