Blogger news

Thursday, 23 October 2014

Playing Audio sound in MATLAB

clc;
[w,f]=wavread('your file name');
player = audioplayer(w, f)
sound(w,f)
% new_w=w(1:500);
% stem(new_w)%   /* see what it sounds like */
t=0:1/f:(length(w)-1)/f;
n=length(w)
max_w=max(w)
min_w=0
delta=(max_w+min_w)/256
normal=(w/max_w);
plot(t,w,'r');
grid on

Sunday, 10 August 2014

Summation of even and odd element of matrix using MATLAB

clc;
m=input('ROW=');
n=input('Cloumn=');
x=randi([2,5],m,n)

Evensum=0;
oddsum=0;
for i=1:1:m

Saturday, 9 August 2014

Leap year calculation using MATLAB code

clc;
Y=input('Please insert Your Year=');
if mod(Y,4)==0
    disp('This year is leap year');
elseif mod(Y,4)==0
     disp('This year is leap year');
else
    disp('This year is not leap year');
end

Saturday, 12 July 2014

Ploting in MATLAB

Three-dimensional plots typically display a surface defined by a function
in two variables, z = f (x,y).
To evaluate z, first create a set of (x,y) points over the domain of the function
using meshgrid.
[X,Y] = meshgrid(-2:.2:2);
Z = X .* exp(-X.^2 - Y.^2);
Then, create a surface plot.
surf(X,Y,Z)




for sub plot:
Subplots
You can display multiple plots in different subregions of the same window
using the subplot function.
For example, create four plots in a 2-by-2 grid within a figure window.
t = 0:pi/10:2*pi;
[X,Y,Z] = cylinder(4*cos(t));
subplot(2,2,1); mesh(X); title('X');
subplot(2,2,2); mesh(Y); title('Y');
subplot(2,2,3); mesh(Z); title('Z');
subplot(2,2,4); mesh(X,Y,Z); title('X,Y,Z');

Some Matrix MATLAB functions

size    size of a matrix
det     determinant of a square matrix
inv       inverse of a matrix
rank      rank of a matrix
rref       reduced row echelon form
eig            eigenvalues and eigenvectors
poly        characteristic polynomial
norm       norm of matrix (1-norm, 2-norm, ∞ -norm)
cond       condition number in the 2-norm
lu LU      factorization
qr QR       factorization
chol      Cholesky decomposition
svd       singular value decomposition

Saturday, 5 July 2014

Drawing BD flag using C programming code

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
 main ()
{
int driver,mode,i,j;
clrscr();

driver=DETECT;
  initgraph(&driver,&mode,"c:\\tc\\bgi"); // here you have to change the directory.if you install your software at "D" drive then you have write(&driver,&mode,"d:\\tc\\bgi")

  for(i=0;i<120;i++)
  {
  for(j=0;j<64;j++)
  {
  rectangle(0+j*50,0+i*40,50+j*50,40+i*40);
  }
  }
  setcolor(6);
  setbkcolor(2);
  setfillstyle(1,6);
  for(i=0;i<120;i++)
  {
  for(j=0;j<64;j++)
  {
  circle(25+j*50,20+i*40,10);
  floodfill(25+j*50,20+i*40,6);
  }
  }

getch();
}

Friday, 4 July 2014

Designing a Voltage Divider Biasing Circuit



Required Equipments:
                   Voltage Source of 5-10V.
                   Four resistor of 1 K.
                   One resistor of 1.5K.
                   One resistor of 2.2K.
                   One BJT (C828).



Circuit Diagram: