Stefan, I was just playing around in Julia to compare with matlab. Here's 
the code, on where and why I needed  linspace to return a vector. Pretty 
common use cases for laying a grid  in space, when trying to solve PDEs

Also Julia code suggestions welcome ;)

function gp(n)
n = convert(Int,n)
t0 = 0
tf = 5
t = collect( linspace(t0, tf, n+1) )
sigma = exp( -(t - t[1]) )

c = [sigma; sigma[(end-1):-1:2]]
lambda = fft(c)
eta = sqrt(lambda./(2*n))

Z = randn(2*n) + im*randn(2*n)
x = real( fft( Z.*eta ) )
return (x, t)
end





On Tuesday, September 29, 2015 at 8:59:52 PM UTC-4, Stefan Karpinski wrote:
>
> I'm curious why you need a vector rather than an object. Do you mutate it 
> after creating it? Having linspace return an object instead of a vector was 
> a bit of a unclear judgement call so getting feedback would be good.
>
> On Tuesday, September 29, 2015, Patrick Kofod Mogensen <
> [email protected] <javascript:>> wrote:
>
>> No:
>>
>> julia> logspace(0,3,5)
>> 5-element Array{Float64,1}:
>>     1.0    
>>     5.62341
>>    31.6228 
>>   177.828  
>>  1000.0   
>>
>> On Tuesday, September 29, 2015 at 8:50:47 PM UTC-4, Luke Stagner wrote:
>>>
>>> Thats interesting. Does logspace also return a range?
>>>
>>> On Tuesday, September 29, 2015 at 5:43:28 PM UTC-7, Chris wrote:
>>>>
>>>> In 0.4 the linspace function returns a range object, and you need to 
>>>> use collect() to expand it. I'm also interested in nicer syntax.
>>>
>>>

Reply via email to