integrate
Integrate cfit
object
Description
Examples
Find the Integral of a Fit Using the integrate
Function
Create a baseline sinusoidal signal.
xdata = (0:.1:2*pi)'; y0 = sin(xdata);
Add response-dependent Gaussian noise to the signal.
noise = 2*y0.*randn(size(y0)); ydata = y0 + noise;
Fit the noisy data with a custom sinusoidal model.
f = fittype('a*sin(b*x)'); fit1 = fit(xdata,ydata,f,'StartPoint',[1 1]);
Find the integral of the fit at the predictors.
int = integrate(fit1,xdata,0);
Plot the data, the fit, and the integral.
subplot(2,1,1) plot(fit1,xdata,ydata) % cfit plot method subplot(2,1,2) plot(xdata,int,'m') % double plot method grid on legend('integral')
You can also compute integrals and plot them directly with the cfit
plot
method:
figure plot(fit1,xdata,ydata,{'fit','integral'})
The plot
method, however, does not return data on the integral.
Input Arguments
fun
— cfit
function
cfit
Function to integrate, specified as a cfit
object.
x
— Integration points
vector
Points at which to integrate the function, specified as a vector.
x0
— First point of integration
scalar
First point of integration, specified as a scalar.
Output Arguments
int
— Integration results
vector
Result of the integration, returned as a vector of the same size of x.
Version History
Introduced before R2006a
Apri esempio
Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)