MATLAB: Area under gaussian curve

gauss

Hi guys
I want the value of area_under_curve to be exactly 30000 from 8.5 to 17
Is this way true to use integral?
Using matlab R2019b
clc;
clear;
close all;
gauss = @(x,mu,sig,amp,vo)amp*exp(-(((x-mu).^2)/(2*sig.^2)))+vo;
x = linspace(8.5,17,1000000);
mu = 12;
sig = 1.19895;
amp = 10000;
vo = 0;
gauss = gauss(x,mu,sig,amp,vo);
plot(x, gauss/1000, 'g-', 'LineWidth',.1)
gauss = @(x)amp*exp(-(((x-mu).^2)/(2*sig.^2)))+vo;
arear_under_crve = integral(gauss,8.5,17);

Best Answer

Define ‘gauss’ as:
gauss = @(x,amp) amp*exp(-(((x-mu).^2)/(2*sig.^2)))+vo;
and:
arear_under_crve = @(amp) integral(@(x)gauss(x,amp),8.5,17);
then:
amp = fsolve(@(amp) arear_under_crve(amp) - 30000, 1)
produces:
amp =
9999.98895298012
.