Clear[Nb]
Nb[m_?NumericQ] :=
Table[NIntegrate[i*m, {ebar, i, (i + 1)}], {i, 1., 10}];
NMaximize[{Nb[m], 800 <= m <= 1200}, {m}]
I have the following error :
NMaximize::nnum: The function value {-818.293,-1636.59,-2454.88,-3273.17,-4091.46,-4909.76,-5728.05,-6546.34,-7364.63,-8182.93}
is not a number at {m} = {818.293}. >>
I guess the problem comes from ?NumericQ, but I must put it (or the Integrand is non numerical for NMaximize)
Clear[Nb]
int[m_, i_] := NIntegrate[m*i, {x, i, i + 1}]
Nb[m_?NumericQ] := Table[int[m, i], {i, 1., 10}];
NMaximize[{Nb[m][[5]], 800 <= m <= 1200}, {m}]
Part::partw: Part 5 of Nb[m] does not exist. >>
Part::partw: Part 5 of Nb[m] does not exist. >>
Part::partw: Part 5 of Nb[m] does not exist. >>
General::stop: Further output of Part::partw will be suppressed during this calculation. >>