julia

Julia: delete rows and columns from an array or matix

痞子三分冷 提交于 2021-02-20 09:18:48
问题 How can I delete one or more rows and/or columns from an array? 回答1: Working with: julia> array = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16] 4×4 Array{Int64,2}: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 To delete a single row (here row 2): julia> newarray = array[1:end .!= 2, :] 3×4 Array{Int64,2}: 1 2 3 4 9 10 11 12 13 14 15 16 To delete a single column (here column 3): julia> newarray = array[:, 1:end .!= 3] 4×3 Array{Int64,2}: 1 2 4 5 6 8 9 10 12 13 14 16 To delete a single row and a single

Julia: delete rows and columns from an array or matix

℡╲_俬逩灬. 提交于 2021-02-20 09:16:07
问题 How can I delete one or more rows and/or columns from an array? 回答1: Working with: julia> array = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16] 4×4 Array{Int64,2}: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 To delete a single row (here row 2): julia> newarray = array[1:end .!= 2, :] 3×4 Array{Int64,2}: 1 2 3 4 9 10 11 12 13 14 15 16 To delete a single column (here column 3): julia> newarray = array[:, 1:end .!= 3] 4×3 Array{Int64,2}: 1 2 4 5 6 8 9 10 12 13 14 16 To delete a single row and a single

Julia: delete rows and columns from an array or matix

南楼画角 提交于 2021-02-20 09:16:06
问题 How can I delete one or more rows and/or columns from an array? 回答1: Working with: julia> array = [1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16] 4×4 Array{Int64,2}: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 To delete a single row (here row 2): julia> newarray = array[1:end .!= 2, :] 3×4 Array{Int64,2}: 1 2 3 4 9 10 11 12 13 14 15 16 To delete a single column (here column 3): julia> newarray = array[:, 1:end .!= 3] 4×3 Array{Int64,2}: 1 2 4 5 6 8 9 10 12 13 14 16 To delete a single row and a single

How to play any waveform's audio in julia language?

不打扰是莪最后的温柔 提交于 2021-02-20 06:20:12
问题 I have a sinusoid with length 5 seconds as below: x=sin(0:.01:2*pi*500*5); Now I would like to hear the audio of this waveform by giving a command similar as below: playsound(x,samplingfrequency); It will be useful for me if I could write this audio data to a wav or mp3 file. What is the library needed and the equivalent command in julia for this functionality? 回答1: You may play audio with https://github.com/ssfrr/AudioIO.jl And for write/read wav https://github.com/JuliaLang/Sound.jl/blob

How to play any waveform's audio in julia language?

此生再无相见时 提交于 2021-02-20 06:18:25
问题 I have a sinusoid with length 5 seconds as below: x=sin(0:.01:2*pi*500*5); Now I would like to hear the audio of this waveform by giving a command similar as below: playsound(x,samplingfrequency); It will be useful for me if I could write this audio data to a wav or mp3 file. What is the library needed and the equivalent command in julia for this functionality? 回答1: You may play audio with https://github.com/ssfrr/AudioIO.jl And for write/read wav https://github.com/JuliaLang/Sound.jl/blob

How to define a function inside a function depending on variable values

强颜欢笑 提交于 2021-02-19 01:40:45
问题 I'm writing a function that I would find easier to write and read if it could define another function differently depending on input or runtime values of variables (and then use that function). The following illustrates the idea (even if defining a function inside a function is of no advantage in this simple example): julia> function f(option::Bool) if option g() = println("option true") g() else g() = println("option false") g() end end; WARNING: Method definition g() in module Main at REPL

Why couldn't Julia superset python?

谁说我不能喝 提交于 2021-02-18 23:51:07
问题 The Julia Language syntax looks very similar to python, while the concept of a class (if one should address it as such a thing) is more what you use in C. There were many reasons why the creators decided on the difference with respect to the OOP. Still would it have been so hard (in comparison to create Julia in first place which is impressive) to find some canonical way to interpret python to Julia and thus get a hold of all the python libraries? 回答1: Yes. The design of Python makes it

Why couldn't Julia superset python?

拟墨画扇 提交于 2021-02-18 23:47:30
问题 The Julia Language syntax looks very similar to python, while the concept of a class (if one should address it as such a thing) is more what you use in C. There were many reasons why the creators decided on the difference with respect to the OOP. Still would it have been so hard (in comparison to create Julia in first place which is impressive) to find some canonical way to interpret python to Julia and thus get a hold of all the python libraries? 回答1: Yes. The design of Python makes it

Memory allocations in Julia

天大地大妈咪最大 提交于 2021-02-18 21:01:44
问题 I'm extremely dissatisfied after translating a program from Python to Julia: for small/very small inputs, Python is faster for medium inputs, Julia is faster (but not that much) for big inputs, Python is faster I think the reason is that I don't understand how memory allocation works (autodidact here, no CS background). I would post my code here but it is too long and too specific and it would not be beneficial for anybody but me. Therefore I made some experiments and now I have some

Gadfly.jl : How to plot date time based?

情到浓时终转凉″ 提交于 2021-02-18 11:38:25
问题 I'm trying to plot data based on time : userId = 2 dateGiven = Datetime.date(2014,2,3) biometric = "heart-rate" df = DataFrames.readtable(string("data/user_",userId,"/",dateGiven,"/",biometric,".csv"), colnames = ["Time", "Heart Rate"], coltypes = {Int,Int} ) df["Time"] = map((timestamp) -> Datetime.unix2datetime(timestamp, Datetime.UTC) , df["Time"]) plot(df,x="Time",y="Heart Rate",Geom.line) I have this error : no method *(Float64,DateTime{ISOCalendar,Zone0}) in optimize_ticks at /Users