Integral of equation with vectors
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Mikkel
il 29 Feb 2016
Commentato: Andrei Bobrov
il 29 Feb 2016
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
0 Commenti
Risposta accettata
Andrei Bobrov
il 29 Feb 2016
Modificato: Andrei Bobrov
il 29 Feb 2016
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 Commenti
Più risposte (1)
Torsten
il 29 Feb 2016
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.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!