Borrar filtros
Borrar filtros

How to integrate dataset over a certain domain ?

6 visualizaciones (últimos 30 días)
Sumit Saha
Sumit Saha el 22 de Abr. de 2021
Comentada: Star Strider el 23 de Abr. de 2021
clear all
close all
clc
load data.txt
S_v = data(:,2);
T = data (:,1);
I_H = trapz(S_v); %Spectral_Intensity
Here it integrates over the whole domain. But how can I integrate within the specified range ?

Respuesta aceptada

Star Strider
Star Strider el 22 de Abr. de 2021
Perhaps:
load data.txt
S_v = data(:,2);
T = data (:,1);
Trange = (T >= 0.1) & (T <= 2.5);
I_H = trapz(T(Trange), S_v(Trange)); %Spectral_Intensity
will do what you want. (Not able to test it without ‘data.txt’.)
Do not use clear or clc. It is simply inefficient.
  2 comentarios
Sumit Saha
Sumit Saha el 23 de Abr. de 2021
@Star Strider Thank you so much. I just want to ask that for such integration using trapz command is completely okay? Because I'm calculating all these things for earthquake engineering.
Star Strider
Star Strider el 23 de Abr. de 2021
As always, my pleasure!
With vectors or arrays, the trapz funciton is the only option. The other integration functions require function handle arguments, and integrate the functions themselves between specific limits.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by