Monday 24 February 2014

MATLAB : Fast Fourier Transform

Fast Fourier Transform : MATLAB :

function y = FourierT(x, dt)
% FourierT(x,dt) computes forward FFT of x with sampling time interval dt
% FourierT approximates the Fourier transform where the integrand of the
% transform is x*exp(2*pi*i*f*t)
% For NDE applications the frequency components are normally in MHz,
% dt in microseconds
[nr, nc] = size(x);
if nr == 1
N = nc;
else
N = nr;
end
y = N*dt*ifft(x);


Sunday 23 February 2014

Windows command line commands : To copy files

Windows command line commands to copy files:


COPY :

Copy one or more files to another location .

Syntax
      COPY source destination [options]

      COPY source1 + source2.. destination [options]

Key
     source :  Pathname for the file or files to be copied.

        /A  :  ASCII text file (default)
        /B  :  Binary file copy - will copy extended characters.

destination :  Pathname for the new file(s).

        /V  :  Verify that the new files were written correctly.

        /N  :  If at all possible, use only a short filename (8.3) when creating a destination file. This may be necessary when copying between disks that are formatted differently e.g NTFS and VFAT, or when archiving data to an ISO9660 CDROM.

        /Z  :  Copy files in restartable mode. If the copy is interrupted part way through, it will restart if possible. 

Examples:

To copy file from source to destination 
COPY sourcefile.doc destinationfile.doc

To copy from a different folder/directory: 
COPY "C:\myfolder\sourcefile.doc" "D:\Newfolder\destinationfile.doc"

To copy all the files into the current directory specify the source only, with a wildcard:
COPY "C:\myfolder\*.doc"

To copy all the files to a different directory:
COPY "C:\myfolder\*.txt" "D:\Newfolder\destfiles.txt" 

To have no feedback on screen while copying , specify the following command :
COPY sourcefile.doc destinationfile.doc >nul

Tuesday 26 November 2013

JAVASCRIPT : Factorial of a Number

JavaScript : Factorial of a Number :

Here is the code for the Factorial of a number in JavaScript code :

<script type = "text/javascript">
            var n = parseInt(window.prompt("Enter Number To Find Its Factorial:"));
            var result = fact(n);
            window.alert("Factorial of the given number " + result);
            function fact(n)
            {
                if(n == 0)
                    return 1;
                else 
                    return (n*fact(n-1));
            }
</script>

Output :

Enter Number To Find Its Factorial: 3
3 ! =  6 

PYTHON : Factorial of a Number

Factorial of a Number :

Here is the code for the Factorial of a number in Python code :


def Fact(n):
   if( n <= 1):
        return 1
   return n * Fact(n - 1)


val = 0
print " Enter Number To Find Its Factorial: ",
val = input()
print val, " !=", Fact(val)

Output :

Enter Number To Find Its Factorial:  3
3 ! =  6    

C++ : Factorial of a Number

Factorial of a Number :

Here is the code for the Factorial of a number in C++ code :

#include<iostream>
using namespace std;
int main()
{
    int num,factorial=1;
    cout<<" Enter Number To Find Its Factorial:  ";
    cin>>num;
    for(int a=1;a<=num;a++)
    {
        factorial=factorial*a;
    }
cout<<"Factorial of Given Number is ="<<factorial<<endl;
    return 0;
}
  

Output :

Enter Number To Find Its Factorial: 3

0! = 1
1! = 1
2! = 2
3! = 6


Friday 22 November 2013

ASSEMBLY LANGUAGE : Fibonacci Series


Fibonacci Series :

Here is the code for the Fibonacci Series in the Assembly Language program :

2000  MVI D,07 H
2002  MVI B,00 H
2004  MVI C,01 H
2006  MOV A,B
2007  ADD C
2008  MOV B,C
2009  MOV C,A
200A DCR D
200B JNZ 2006
200E END


Output :

1
1
2
3
5
8
13

To know about the Fibonacci Series in detail and also to know the codes of the Fibonacci Series in various other programming languages Click Here

If the above link doesn't work go to this URL :

PERL : Fibonacci Series


Fibonacci Series :

The below code explains the Fibonacci series in PERL programming language :

use warnings;
use strict;

my $f1=0;
my $f2=1;
my ( $n, $i, $f3 ) ;

print "\n*** FIBONACCI SERIES ***\n";
chomp ( $n = <STDIN> ) ;

printf ("$f1\t$f2") ;

for ( $i = 0 ; $i<$n-2 ; $i++ )
{
         $f3 = $f1+$f2 ;
         $f1 = $f2 ;
         $f2 = $f3 ;
         printf ("\t$f3");
}

Output :

1
1
2
3
5
8
13

To know about the Fibonacci Series in detail and also to know the codes of the Fibonacci Series in various other programming languages Click Here

If the above link doesn't work go to this URL :