Integration of Numeric Data

4 ビュー (過去 30 日間)
Pushkar K
Pushkar K 2023 年 6 月 19 日
回答済み: Askic V 2023 年 6 月 20 日
Hello, I am currently working on turbulent boundary layers and facting problem in Numeric Integration. I have a variable Beta9 ( a column vector - 3201x1 double) and rtheta59BL (a column vector - 3250x1 double). I have to integrate Beta9 over rtheta59BL. I tried to use trapez method but couldnt solve it. Could anyone please help.
  1 件のコメント
Torsten
Torsten 2023 年 6 月 19 日
Arrange the vectors such that they have the same size. Each value Beta9(i) must correspond to rtheta59BL(i).

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

回答 (1 件)

Askic V
Askic V 2023 年 6 月 20 日
I think this small code snippet would be sufficient to give you an idea how to proceed further:
clc;
clear;
% Just for the purpose of example
x = linspace(-4,2, 20); % 20 points
y = x.^2+2*x+5; % vector y also has 20 points
Z = trapz(x,y) % calculate area under the curve
Z = 42.0997
subplot(211)
plot(x,y);
hold on
stem(x,y);
hold off
% If there is a new vector with 50 points
x2 =linspace(-4,2,50);
% Z = trapz(x2,y); will produce an error
% First y vector needs to be interpolated with additional points
desiredNrPoints = numel(x2);
newInd = linspace(1, numel(y),desiredNrPoints);
y2 = interp1(y, newInd);
Z2 = trapz(x2,y2)
Z2 = 42.1147
subplot(212)
plot(x2,y2);
hold on
stem(x2,y2);
hold off

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by