I have the blog MultiSign, and I decided to begin a new work starting this week.
I'm offering services of research and development (R&D) and consulting.
I'll help everyone that asks me using this blog, the services of R&D and consulting are for "bigger helps" necessities.
This is the advertising about what I'm offering. If you're interested, you may tell me.
Any questions, everyone can use this blog too.
Scilab is a software of scientific simulation. It can operate with vectors, matrices, images, state space, and other kinds of situations. I've been working with Scilab since 2005, and I always have success in my projects using Scilab.
Sunday, March 21, 2010
Monday, March 15, 2010
Discrete Fourier Transform - DFT
I made some posts about Discrete Fourier Transform (DFT), they're here.
But, I received a comment asking me how to do a function that implements DFT.
Let's only write a script, not optimized, that calculates DFT:
function X = DFT(x)
n = length(x); //number of elements in 'x'
omega = exp(-2*%pi*%i/n);
j=0:(n - 1);
F=omega.^(j'*j); //Fourier matrix
X = F*x(:); //X = DFT(x)
endfunction;
If anyone wants to try the showed function, you could do like this:
N = 10;
x = rand(N, 1);
X1 = DFT(x)
X2 = dft(x, -1) // dft(.) function uses flag = -1 for direct transform and flag = 1 for inverse transform
X3 = fft(x)
Now, look the values of X1, X2 and X3.
Did I help?
But, I received a comment asking me how to do a function that implements DFT.
Let's only write a script, not optimized, that calculates DFT:
function X = DFT(x)
n = length(x); //number of elements in 'x'
omega = exp(-2*%pi*%i/n);
j=0:(n - 1);
F=omega.^(j'*j); //Fourier matrix
X = F*x(:); //X = DFT(x)
endfunction;
If anyone wants to try the showed function, you could do like this:
N = 10;
x = rand(N, 1);
X1 = DFT(x)
X2 = dft(x, -1) // dft(.) function uses flag = -1 for direct transform and flag = 1 for inverse transform
X3 = fft(x)
Now, look the values of X1, X2 and X3.
Did I help?
Tuesday, March 9, 2010
Fractions with numerator and denominator
I received a comment here.
The commentator asked me how to show a fraction as same as it was inserted.
For example:
x = 1/2;
disp(x)
1
-
2
So, I made a simple form for it.
-->function [x] = frac(n, d)
--> x = (n*%s)/(d*%s);
-->endfunction;
-->x1 = frac(1, 2);
-->disp(x1);
1
-
2
-->x2 = frac(2, 3);
-->disp(x2);
2
-
3
-->disp(x1 + x2);
7
-
6
-->disp(x1*x2);
2
-
6
-->x1 + 1
ans =
3
-
2
-->x1 + x2 - 2
ans =
- 5
-
6
PS.: The element %s is used in polynomial definitions.
Is it all right now?
The commentator asked me how to show a fraction as same as it was inserted.
For example:
x = 1/2;
disp(x)
1
-
2
So, I made a simple form for it.
-->function [x] = frac(n, d)
--> x = (n*%s)/(d*%s);
-->endfunction;
-->x1 = frac(1, 2);
-->disp(x1);
1
-
2
-->x2 = frac(2, 3);
-->disp(x2);
2
-
3
-->disp(x1 + x2);
7
-
6
-->disp(x1*x2);
2
-
6
-->x1 + 1
ans =
3
-
2
-->x1 + x2 - 2
ans =
- 5
-
6
PS.: The element %s is used in polynomial definitions.
Is it all right now?
Marcadores:
functions,
operations,
polynomials,
variables
Subscribe to:
Posts (Atom)