Julia produces an error when (I think) I specify if b[:,1:NumPlantSpecies].
I want to specify different values for b0 and β when row values are between 1 and the number of plant species (if statement), and between the number of plant species+1 and number of total species (else statement).
function create_b(NumTotalSpecies, log10BM, L)
    b = zeros(NumTotalSpecies, NumTotalSpecies)
    for i = 1:NumTotalSpecies
        for j = 1:NumTotalSpecies
            if b[:,1:NumPlantSpecies] #indicates herbivory
                b0 = 1000 
                β = 0.19   #NOTE how to add ± 0.04 ?
                permutedims(log10BM) = 1 # here (log10BM'^β[i]) * L should = 1
                L = 1 # here (log10BM'^β[i]) * L should = 1
            else #everything else is omnivore or carnivore
                b0 = 50 
                β = 0.42 #NOTE how to add ± 0.05 ?
            end
            b[i,j] = b0 * (log10BM[i]^β) * (log10BM[j]^β) * L[i, j]
        end
    end
    return(b)
end
b = create_b(NumTotalSpecies, log10BM, L)
I understand that Julia was expecting a boolean value (true/false) but I don’t understand why 1:NumPlantSpecies is not a clear boolean criteron.
Necessary code is:
using Distributions, Random
Ropt = 100
γ= 2
q = rand(Normal(0.5,0.2))#Hill exponent, μ = 0.5, σ = 0.2 "within in. limits of 0 and 1"
#rand()is between 0 and 1, unless specified
NumPlantSpecies = 8
NumAnimalSpecies = 12
NumTotalSpecies = NumPlantSpecies + NumAnimalSpecies
log10BM_P = sort(rand(Uniform(10^0, 10^6), NumPlantSpecies))
log10BM_A = sort(rand(Uniform(10^2, 10^12), NumAnimalSpecies)) 
log10BM = vcat(log10BM_P,log10BM_A) 
function create_FoodWeb(log10BM,Ropt,γ) 
    function create_L(log10BM,Ropt,γ) 
        L = @. ((log10BM/(log10BM'*Ropt))' * exp(1-(log10BM/(log10BM'*Ropt))'))^γ
        # Weak links (Lij <p) are removed
        L[L .<= 0.01] .= 0.0
        L[:,1:NumPlantSpecies] .= 0.0
        return(L)
    end
    condition = true
    while condition
        log10BM_P = sort(rand(Uniform(10^0, 10^6), NumPlantSpecies))
        log10BM_A = sort(rand(Uniform(10^2, 10^12), NumAnimalSpecies))
        log10BM = vcat(log10BM_P,log10BM_A)
        global L = create_L(log10BM,Ropt,γ)
        #take the link probabilities of the previous matrix and determine if L[i,j] > p
        global FoodWeb = zero(L)
        FoodWeb[:,1:NumPlantSpecies] .= 0.0 # keeps plants as basal species
        FoodWeb[L .> rand.(Uniform(0, 1))] .= 1.0 # Sets F[i,j] = 0  wherever  L[i,j] < F[i,j]
        condition = any(sum(x->x>0, FoodWeb, dims=1)  + sum(x->x>0, FoodWeb, dims=2)' .== 0.0)
        #dims=(1) for column, dims=(2) for row
    end
    return(log10BM, L, FoodWeb)
end
log10BM,L,FoodWeb = create_FoodWeb(log10BM, Ropt,γ)
function create_b(NumTotalSpecies, log10BM, L)
    b = zeros(NumTotalSpecies, NumTotalSpecies)
    for i = 1:NumTotalSpecies
        for j = 1:NumTotalSpecies
            if b[:,1:NumPlantSpecies] #indicates herbivory
                b0 = 1000 
                β = 0.19   #NOTE how to add ± 0.04 ?
                permutedims(log10BM) = 1 # here (log10BM'^β[i]) * L should = 1
                L = 1 # here (log10BM'^β[i]) * L should = 1
            else #everything else is omnivore or carnivore
                b0 = 50 
                β = 0.42  #NOTE how to add ± 0.05 ?
            end
            b[i,j] = b0 * (log10BM[i]^β) * (log10BM[j]^β) * L[i, j]
        end
    end
    return(b)
end
b = create_b(NumTotalSpecies, log10BM, L)