How to find the integral of some values?

Hello community!
I have a file on excel with some values which are the output signal. So, I want to find the integral of these values.
How to do that in Matlab or Simulink?
PS. I have imported the excel file on workspace
Thanks in advance!

 Respuesta aceptada

Star Strider
Star Strider el 27 de Jun. de 2020

0 votos

use the trapz (or cumtrapz) function (depending on the result you want). It would be best to also have an independent variable (for example, time) as well as part of the integration, if you have access to it.

6 comentarios

RoBoTBoY
RoBoTBoY el 27 de Jun. de 2020
Editada: RoBoTBoY el 27 de Jun. de 2020
I changed the excel file with a new one which have time inside.
I run this function but i took this error
Your comment does not give me enough information, since I do not have the file you are using, or the code you are using to read it.
However using the available data and creating a ‘Time’ vector for it to test the code, this works:
T1 = readtable('Vout.xlsx', 'PreserveVariableNAmes',1);
Time = table(linspace(0, numel(T1(:,1)), numel(T1(:,1))).'*1E-3, 'VariableNames',{'Time'}); % Create ‘Time’ Vector
T1 = [Time T1];
IntVdt = trapz(T1{:,1}, T1{:,2}); % Integral Of 'Vout' With Respect To Time
Make appropriate changes to get it to work with your table. It works with this one.
.
RoBoTBoY
RoBoTBoY el 27 de Jun. de 2020
Could you explain furthermore what will change in above code?
I had a column with time in my file.
Star Strider
Star Strider el 27 de Jun. de 2020
Assuming that your table is like the one I created, just use the ‘IntVdt’ assignment to calculate the integral. If it is differen, I need to know the details of the one you are using.
My code extracts the numerical values from the table (note the curly braces {}) and uses them as arguments to trapz. See the documentation on table for more informaiton on how to get data from them.
RoBoTBoY
RoBoTBoY el 28 de Jun. de 2020
Thank you very much!
Star Strider
Star Strider el 28 de Jun. de 2020
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 27 de Jun. de 2020

Comentada:

el 28 de Jun. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by