필터 지우기
필터 지우기

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 CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by