Nils
Just to be clear I am trying to get the following to work, but get error below. This test problem better reflects my real world problem. Hoping you can help
using CSV
using DataFrames
using DelimitedFiles
function foo()
out= zeros(5,12)
# y=zeros(5,10)
y=zeros(10) # Column vectors
a=zeros(5)
b=zeros(5)
for i in 1:5
a[i]=1 # test data
b[i]=2 # test data
# y=rand(10, 10) # test data
y=rand(10)
# out[i,:] = vcat(y[i,:],a[i],b[i])
out[i,:] = vcat(transpose(y),a[i],b[i])
end
CSV.write("MyOutput.csv", Tables.table(out),delim=',',decimal='.')
end
foo()
ERROR: LoadError: DimensionMismatch("mismatch in dimension 2 (expected 10 got 1)")
Stacktrace:
[1] _cs at .\abstractarray.jl:1501 [inlined]
[2] _cshp at .\abstractarray.jl:1487 [inlined]
[3] _cshp at .\abstractarray.jl:1498 [inlined]
[4] cat_shape(::Tuple{Bool}, ::Tuple{Int64,Int64}, ::Tuple{Int64}, ::Tuple{Int64}) at .\abstractarray.jl:1476 (repeats 2 times)
[5] _cat_t(::Val{1}, ::Type{T} where T, ::LinearAlgebra.Transpose{Float64,Array{Float64,1}}, ::Vararg{Any,N} where N) at .\abstractarray.jl:1521
[6] cat_t(::Type{Float64}, ::LinearAlgebra.Transpose{Float64,Array{Float64,1}}, ::Vararg{Any,N} where N; dims::Val{1}) at .\abstractarray.jl:1518
[7] _cat at .\abstractarray.jl:1516 [inlined]
[8] #cat#111 at .\abstractarray.jl:1654 [inlined]
[9] vcat at .\abstractarray.jl:1583 [inlined]
[10] foo() at c:\Users\peter\Documents\Julia_Code\Greenhouse_Model\Green-Lights-main\Test_Adding_Data.jl:23
[11] top-level scope at c:\Users\peter\Documents\Julia_Code\Greenhouse_Model\Green-Lights-main\Test_Adding_Data.jl:29
[12] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1088
[13] include_string(::Module, ::String, ::String) at .\loading.jl:1096
[14] invokelatest(::Any, ::Any, ::Vararg{Any,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at .\essentials.jl:710
[15] invokelatest(::Any, ::Any, ::Vararg{Any,N} where N) at .\essentials.jl:709
[16] inlineeval(::Module, ::String, ::Int64, ::Int64, ::String; softscope::Bool) at c:\Users\peter\.vscode\extensions\julialang.language-julia-1.0.10\scripts\packages\VSCodeServer\src\eval.jl:185
[17] (::VSCodeServer.var"#61#65"{String,Int64,Int64,String,Module,Bool,VSCodeServer.ReplRunCodeRequestParams})() at c:\Users\peter\.vscode\extensions\julialang.language-julia-1.0.10\scripts\packages\VSCodeServer\src\eval.jl:144
[18] withpath(::VSCodeServer.var"#61#65"{String,Int64,Int64,String,Module,Bool,VSCodeServer.ReplRunCodeRequestParams}, ::String) at c:\Users\peter\.vscode\extensions\julialang.language-julia-1.0.10\scripts\packages\VSCodeServer\src\repl.jl:124
[19] (::VSCodeServer.var"#60#64"{String,Int64,Int64,String,Module,Bool,Bool,VSCodeServer.ReplRunCodeRequestParams})() at c:\Users\peter\.vscode\extensions\julialang.language-julia-1.0.10\scripts\packages\VSCodeServer\src\eval.jl:142
[20] hideprompt(::VSCodeServer.var"#60#64"{String,Int64,Int64,String,Module,Bool,Bool,VSCodeServer.ReplRunCodeRequestParams}) at c:\Users\peter\.vscode\extensions\julialang.language-julia-1.0.10\scripts\packages\VSCodeServer\src\repl.jl:36
[21] (::VSCodeServer.var"#59#63"{String,Int64,Int64,String,Module,Bool,Bool,VSCodeServer.ReplRunCodeRequestParams})() at c:\Users\peter\.vscode\extensions\julialang.language-julia-1.0.10\scripts\packages\VSCodeServer\src\eval.jl:110
[22] with_logstate(::Function, ::Any) at .\logging.jl:408
[23] with_logger at .\logging.jl:514 [inlined]
[24] (::VSCodeServer.var"#58#62"{VSCodeServer.ReplRunCodeRequestParams})() at c:\Users\peter\.vscode\extensions\julialang.language-julia-1.0.10\scripts\packages\VSCodeServer\src\eval.jl:109
[25] #invokelatest#1 at .\essentials.jl:710 [inlined]
[26] invokelatest(::Any) at .\essentials.jl:709
[27] macro expansion at c:\Users\peter\.vscode\extensions\julialang.language-julia-1.0.10\scripts\packages\VSCodeServer\src\eval.jl:27 [inlined]
[28] (::VSCodeServer.var"#56#57")() at .\task.jl:356
in expression starting at c:\Users\peter\Documents\Julia_Code\Greenhouse_Model\Green-Lights-main\Test_Adding_Data.jl:29```