# exjl3.jl declare and print variable, vector, matrix using Printf # only needed if @printf will be used println("julia exjl3.jl running") s1 = "any string" println(s1) s2 = "more" println(s2) s3 = s1*s2 # concatenation println(s3) s4 = s1*" "*s2 # space between strings println(s4) i = 13 # integer Int print("i = ") print(i) # print can print everything, even arrays println(" ") # no line feed in just print @printf "i = %d \n" i # "C" format and list x = 0.0 # double Float64 @printf "x=%f \n" x for i in 1:4 global x x = x + 1.0 end @printf "x=%f \n" x v1 = [ 1 2 3 4 ] # row vector no comma print("v1=") print(v1) print(" row vector"); println(" ") @printf "v1[3]=%d \n" v1[3] v2 = [1, 2, 3, 4] # typical row vector print("v2=") print(v2) print(" with , row vector"); println(" ") @printf "v2[3]=%d \n" v2[3] v3 = [ 1 2 3 4 ]' # column vector "'" print("v3=") print(v3) print(" with ' column vector"); println(" ") @printf "v3[3]=%d \n" v3[3] # matrix A = Array{Float64,2}(undef, 2, 3) println("A created ") print("A=") print(A) println(" ") A0 = zeros(2, 3) print("A0=") print(A0) println(" ") A1 = ones(2, 3) print("A1=") print(A1) println(" ") B = [1.0 2.0 3.0 ; 4.0 5.0 6.0] # no commas! ; or new line print("B=") print(B) println(" ") nrow = size(B,1) print("nrow=size(B,1)=") println(nrow) ncol = size(B,2) print("ncol=size(B,2)=") println(ncol) println(" ") println("exjl3.jl finished") # end exjl3.jl