[Scilab-users] inttrap

haasejos haasejos at web.de
Sat Dec 8 14:10:18 CET 2012


*hallo,
I want to compare several calculations for fourier coefficients (see
example):*
clear; clc; xdel;
 
function f_x = RECHTECK();
// Berechnung der Rechteckfunktion  
  f_x(1:20) = 1;
  f_x(21:40) = -1;  
endfunction

x = linspace (0 , 2*%pi , 40);
f_x = RECHTECK();
//m = [x',f_x];
//disp(m);
//plot2d(x',f_x);

//0-ter Fourierkoeffizient
a_0 = (1/%pi)*inttrap(x , f_x); 
//disp('a_0 = ' +string(a_0));

c_0 = a_0 / 2;

//1te Fourierkoeffizienten
a_1 = (1/%pi) * inttrap(x , (f_x .* cos(1*x)'));
//disp('a_1 = ' +string(a_1));
b_1 = (1/%pi) * inttrap(x , (f_x .* sin(1*x)'));
//disp('b_1 = ' +string(b_1));

c_11 = (a_1 - %i * b_1) / 2;
c_12 = (a_1 + %i * b_1) / 2;

c_11_i = 1/(2*%pi) * inttrap(x , f_x .* (%e^((-%i) * 1 * x))');
c_12_i = 1/(2*%pi) * inttrap(x , f_x .* (%e^((-%i) * (-1) * x))');

disp ([c_11 c_11_i c_12 c_12_i]);
abort;

*As it can be seen, c_11_i = - c_11. Can this NOT be done by inttrap? What
else am I doing wrong?
thanks in advance for your help
Josef  * 



--
View this message in context: http://mailinglists.scilab.org/inttrap-tp4025444.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list