フィルターのクリア

Integral of equation with vectors

1 回表示 (過去 30 日間)
Mikkel
Mikkel 2016 年 2 月 29 日
コメント済み: Andrei Bobrov 2016 年 2 月 29 日
clc; clear all;
%%Test of Intergral
t = (0:0.5:8); % Timestep and interval
h = 10; % Water height
H = 4; % Wave height
a = [0 -0.7 -1.4 -1.8 -2.0 -1.9 -1.5 -0.9 -0.2 0.5 1.1 1.6 1.9 1.9 1.6 1.1 0.4]; % accelerations
u = [2.6 2.4 1.9 1.1 0.1 -0.8 -1.6 -2.3 -2.6 -2.5 -2.1 -1. -0.4 0.5 1.4 2.1 2.5]; % Velocity
D = 2; % Diameter
syms x
f(x) = pi.*(D/2)^2.*x.*a+1/2.*u.*abs(u).*D.*x; % My Function
p = arrayfun(@(x)integral(f(x),0,10)); %<--- first try integral this from the range of 0 to 10
g(x) = integral(f,0,10); %<-- need to integral this from the range of 0 to 10

採用された回答

Andrei Bobrov
Andrei Bobrov 2016 年 2 月 29 日
編集済み: Andrei Bobrov 2016 年 2 月 29 日
h = 10;
H = 4;
a = [0 -0.7 -1.4 -1.8 -2.0 -1.9 -1.5 -0.9 -0.2 0.5 1.1 1.6 1.9 1.9 1.6 1.1 0.4];
u = [2.6 2.4 1.9 1.1 0.1 -0.8 -1.6 -2.3 -2.6 -2.5 -2.1 -1. -0.4 0.5 1.4 2.1 2.5];
D = 2;
f = @(x,a,u) pi.*(D/2)^2.*x.*a+1/2.*u.*abs(u).*D.*x;
p = arrayfun(@(a,u)integral(@(x)f(x,a,u),0,10),a,u);
or try
h = 10;
H = 4;
a = [0 -0.7 -1.4 -1.8 -2.0 -1.9 -1.5 -0.9 -0.2 0.5 1.1 1.6 1.9 1.9 1.6 1.1 0.4];
u = [2.6 2.4 1.9 1.1 0.1 -0.8 -1.6 -2.3 -2.6 -2.5 -2.1 -1. -0.4 0.5 1.4 2.1 2.5];
D = 2;
f = @(x) pi.*(D/2)^2.*x.*a+1/2.*u.*abs(u).*D.*x;
p = integral(f,0,10,'ArrayValued',true);
  2 件のコメント
Mikkel
Mikkel 2016 年 2 月 29 日
It works, thanks. But can you explain why the 'ArrayValued',true <-- what it does?
Andrei Bobrov
Andrei Bobrov 2016 年 2 月 29 日
Please read about ' ArrayValued' in function integral.

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

その他の回答 (1 件)

Torsten
Torsten 2016 年 2 月 29 日
a = [0 -0.7 -1.4 -1.8 -2.0 -1.9 -1.5 -0.9 -0.2 0.5 1.1 1.6 1.9 1.9 1.6 1.1 0.4]; % accelerations
u = [2.6 2.4 1.9 1.1 0.1 -0.8 -1.6 -2.3 -2.6 -2.5 -2.1 -1. -0.4 0.5 1.4 2.1 2.5]; % Velocity
D = 2; % Diameter
fun=@(x,a,u,D) pi.*(D/2)^2.*x.*a+1/2.*u.*abs(u).*D.*x;
p=integral(@(x)fun(x,a,u,D),0,10,'ArrayValued',true);
Best wishes
Torsten.

カテゴリ

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