2017-11-14 8 views
3

In MATLAB (R2017b, Online-Version) habe ich ein Problem bei der symbolischen Integration gefunden: versuchen, Integral von f(t) = abs(sin(t)) zu berechnen. Aufgrund der Tatsache, dass immer positiv ist, erwarte ich, dass das Integral in [a, b] niedriger ist als das Integral in [a, b'] wenn b < b'. Aber:Matlab Integration und abs

int(abs(sin(t)), t, 0, pi) -> 2 % OK 
int(abs(sin(t)), t, 0, 2*pi) -> 2 % NO (should be 4) 

In der Tat, wenn wir die Funktion plotten, die das Integral 0-x darstellen, die monotone sein sollte, fanden wir etwas anderes:

% for each value x(i) of x we will calculate integral from 0 to x(i) 
x = 0 : pi/8 : 4*pi; 
% actual computation 
Z = zeros(length(x), 1);       % create array 
syms t;            % create symbolic variable t 
calculate_int = @(n) int(abs(sin(t)), t, 0, n);  % integral function 
for i = 1 : length(Z) 
    Z(i) = calculate_int(x(i)); 
end 
% plot result 
figure; 
plot(x, Z); 

Ergebnisse in dieser offensichtlich nicht monoton Funktion:

Plot

Nicht symbolische Integration gibt kein Problem:

x = 0 : 0.01 : pi; 
f = abs(sin(x)); 
value = sum(f * 0.01) % 2 

x = 0 : 0.01 : 2 * pi; 
f = abs(sin(x)); 
value = sum(f * 0.01) % 4 
+0

Sind Sie sicher, dass Sie den Code ordnungsgemäß ausführen? Weil ich Ihren Code ausprobiert habe und das ist, was ich bekam: https://imgur.com/eqY2Wme –

+0

@TommasoBelluzzo: Ich kann dies perfekt in der Desktop-Version von R2017b replizieren. – horchler

+2

Dies scheint für R2017b spezifisch zu sein. Ich kann das Problem nicht in R2017a und früher replizieren. Scheint wie ein Fehler. Ich schlage vor, dass Sie [eine Serviceanfrage stellen] (https://www.mathworks.com/support/contact_us/?s_tid=sp_ban_cs). – horchler

Antwort

0

Es ist ein Fehler in Matlab R2017b. Siehe @horchler Kommentare für Details.