Integrating Data points in matlab

12 ビュー (過去 30 日間)
Kunal Tiwari
Kunal Tiwari 2018 年 3 月 19 日
編集済み: Torsten 2018 年 3 月 19 日
I have a set of data points I want to integrate. The signal is force vs time. (ultimate aim is to get fourier series, but taking mini steps by learning to integrate first.) I thought of using,
cumtrapz(t,F) %t is time, F is force
To verify if this method is correct, I created a test signal,
t=0:0.01:25.6;
F=2*sin(0.5*t);
intF=cumtrapz(t,F);
I also found Integration of 2 sin(wt) using,
syms t
int(2*sin(0.5*t))
It came as, -2w cos(wt). After this I plotted all the three signals on one graph.
plot(F);
hold on
plot(intF);
hold on
plot(-4*cos(t/2));
I get the following result.
My question is how to get the correct integration result for numerical data.
  1 件のコメント
Pawel Jastrzebski
Pawel Jastrzebski 2018 年 3 月 19 日
Small off topic: you need only ONE 'hold on' to keep all of the plots in one figure.

サインインしてコメントする。

回答 (1 件)

Torsten
Torsten 2018 年 3 月 19 日
plot(-4*cos(t/2)+4*cos(0/2));
  2 件のコメント
Kunal Tiwari
Kunal Tiwari 2018 年 3 月 19 日
You misunderstood my question.
-4*cos(t/2)=int(2*sin(0.5*t)
I need some data integration function which will not add the bias.
Torsten
Torsten 2018 年 3 月 19 日
編集済み: Torsten 2018 年 3 月 19 日
The numerical result for your integration data is correct, but not your analytical integral:
int(2*sin(0.5*t),0,x) = -4*cos(x/2)+4

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by