Some Great Thoughts

"Go ahead and do your best" | "It is the simple things in life that build brilliance in creativity..simplicity cannot be taught, it is inborn..do not tamper with it" | "All men dream but not equally. Those who dream by night in the dusty recesses of their minds wake in the day to find that it was vanity; but the dreamers of the day are dangerous men, for they may act their dream with open eyes to make it possible" | "इच्छा हमेशा योग्यता को हरा देती है" | "If you think you can do a thing or think you can't do a thing, you're right. -Henry Ford" | "Failure is success if we learn from it. -Malcolm S. Forbes" | "The future belongs to those who believe in the beauty of their dreams. -Eleanor Roosevelt" | "The great men and women of history are remembered, not because they never made mistakes or never failed, but because they didn't let their failures stop them. They kept on until they succeeded" | "असफलता हमें सिखाती है कि सफलता का प्रयत्न पूरे मन से नहीं किया गया"

Wednesday, June 5, 2013

Design of Dualpassband Microwave Filter for 6/4 GHz Band (Satellite Communication)

In satellite communication 6/4 GHz band used in many countries. Commercial communication satellites use a frequency band of 500 MHz bandwidth near 6 GHz for uplink transmission and another 500 MHz bandwidth near near 4 GHz for down link transmission. While an uplink of 5.725 to 7.075 GHz and a downlink of 3.4 to 4.8 GHz is used. For both uplink and downlink band a single dual bandpass filter can be used instead of two band-pass filters.
To design microwave filter well known classical methods like Butterworth, Chebyshev are used but these methods are applicable on single band filters. To design the multipassband filter some limited analytical techniques have been proposed. These all techniques are based on optimization method. Apart from these techniques another technique to design of microwave filter with arbitrary frequency response also proposed which is based on iterative quasi-Newton algorithm. The methodology proposed in this paper  follow this technique and rests on the translation of analog specification of both bands of 6/4 GHz band into digital specification since in digital domain the design is little bit easy. A designer can also take advantage of these sophisticated and continuously developing digital techniques in digital domain.

Following program can be used to design a dualpassband filter for satellite communication:


%% clear the command window & workspace
clear all
clc
%% define the besic perameter related to filter
% order of numerator % denominator
n=10;
d=10;
% frequency range of passbands & stopbands
f1=0:1/1000:.9406;
f2=0.9406:.0001:.9578;
f3=0.9579:.0001:.9645;
f4=.9646:.0001:.9714;
f5=[.9715:1/1000:1 1];
f=[f1 f2 f3 f4 f5];
edges=[0 f(1278:1280)];
% magnitiude to define passbands & stopbands
m1=[repmat(-40,1,900) -40:1:0];
m2=repmat(0,1,173);
m3=[0:-1:-32 -33:1:0];
m4=repmat(0,1,69);
m5=[0:-1:-27 -28.5 -30];
m=[m1 m2 m3 m4 m5];
%% desigining of filter
% conversion of magnitude from dB to normal value
a=db2mag(m);
% define the weight of error
w=repmat(50,1,1280);
% numerator & denominator of digital filter
[num,den]=iirlpnorm(n,d,f,edges,a,w);
% frequency responce of digital filter
figure(1),freqz(num,den)
% transfer function of digital filter
s=tf(num,den,10^(-9));
% pole zero plot of designed digital filter
figure(2),pzplot(s)
% conversion of digital filter from digital to analog
S=d2c(s,'tustin');
% bode plot of analog filter
figure(3),bode(S)
% numerator & denominator of analog filter
[NUM,DEN]=tfdata(S,'v');
% conversion of negative coefficent of numerator & denominator to make
% filter stable
if NUM<0
    NUM=-1*NUM;
end
if DEN<0
    DEN=-1*NUM;
end
% transfer function of analog filter with new coefficents
S1=tf(NUM,DEN);
% bode plot of analog filter with new coefficents
figure(4),bode(S1)

%% end of designing program

The frequency response for designed filter will be: 

Monday, December 24, 2012

Merry Christmas

Play With MATLAB wish u all a Merry Christmas... here I hv a beautiful Christmas Tree to all of you which is designed using MATLAB:

Program For this Beautiful Christmas Tree:
function christmas

% Anselm Ivanovas, anselm.ivanovas@student.unisg.ch

%Basically just a nice plot for some christmas fun.
%3D Plot of a hhristmas tree with some presents and snow

%% setup
snow=800;     % number of snow flakes [0 .. 5000]


%% draw tree
h=0:0.2:25; %vertical grid
[X,Y,Z] = cylinder(tree(h)); %produce a tree formed cylinder
Z=Z*25; %scale to the right heigth

%Add some diffusion to the surface of the tree to make it look more real

treeDiffusion=rand(126,21)-0.5;%some horizontal diffusion data

%add diffusion to the grid points 
for cnt1=1:21
    
    for cnt2=16:126%starting above the trunk
        %get the angle to always diffuse in direction of the radius
        angle=atan(Y(cnt2,cnt1)/X(cnt2,cnt1));
        %split the diffusion in the two coordinates, depending on the angle
        X(cnt2,cnt1)=X(cnt2,cnt1)+cos(angle)*treeDiffusion(cnt2,cnt1);
        Y(cnt2,cnt1)=Y(cnt2,cnt1)+sin(angle)*treeDiffusion(cnt2,cnt1);
        %some Vertical diffusion for each point
        Z(cnt2,cnt1)=Z(cnt2,cnt1)+(rand-0.5)*0.5;
    end
    
end
%draw the tree
surfl(X,Y,Z,'light')

%% View and format

%Use as nice green color map (darker at the bottom, lighter at the top)
r=(0.0430:(0.2061/50):0.2491)';%red component
g=(0.2969:(0.4012/50):0.6981)';%green component
b=(0.0625:(0.2696/50):0.3321)';%blue component
map=[r,g,b];%join in a map
for cnt=1:6
    %change the lower part to brown for the trunk
    map(cnt,:)=[77,63,5]/265;
end

colormap(map)%set the map
view([-37.5,4])%Change the view to see a little more of the Actual 3D tree
lighting phong %some nice lighting
shading interp %remove grid and smoothen the surface color
axis equal %takes care of display in the right proportion
axis([-10 10 -10 10 0 30]) %give some more axis space (for the snow later)
axis off %but don't show axis
hold on %to draw the rest
title('Merry Christmas')%self explaining

%% Presents
%Draw some presents around the tree (each with random color)
drawPresent(2,-4,0,3,3,2);
drawPresent(-4,3,0,2,3,1.5);
drawPresent(5,3,0,4,3,3);
drawPresent(-14,-5,0,6,3,1);
drawPresent(-9,-10,0,2,2,2);
drawPresent(0,4,0,4,3,3);
drawPresent(-6,-13,0,3,3,3);

%% Snow

%create some random 3D coordinates for the snow (amount as in setup above)
snowX=(rand(snow,1)*25-12.5);
snowY=(rand(snow,1)*25-12.5);
snowZ=(rand(snow,1)*27);
%Note:Some flakes will end up IN the tree but just can't be seen then
plot3(snowX,snowY,snowZ,'w*')%plot coordinates as white snow flakes
hold off%Done
end % of function


%% ============= private functions

function r=tree(h)%Gives a profile for the tree
for cnt=1:length(h)
    
    if(h(cnt)==0)%no Width at the bottom. Ensures a "closed" trunk
        r(cnt)=0;
    end
    %smaller radius for the trunk
    if (h(cnt)>0 && h(cnt)<=3)
        r(cnt)=1.5;
    end

    %reduce radius gradually from 8 to 0. Note: will only work with a trunk heigth
    %of 3 and a whole tree heigth of 25. Scale the height of the tree in
    %the "draw tree" section, since the cylinder command will return a 1
    %unit high cylinder anyway
    if(h(cnt)>3)
        r(cnt)=8-(h(cnt)-3)*0.3636;
    end

end

end % of function

%Draws a present with the given coordinate + size in a random color
%Note:Given coordinates apply to the lower front + left corner of the
%present (the one closest to the viewer) as seen in the plot
function drawPresent(dx,dy,dz,scalex,scaley,scalez) 

%the standard present coordinates
presentX=[0.5 0.5 0.5 0.5 0.5; 0 1 1 0 0; 0 1 1 0 0; 0 1 1 0 0; 0.5 0.5 0.5 0.5 0.5];
presentY=[0.5 0.5 0.5 0.5 0.5; 0 0 1 1 0; 0 0 1 1 0; 0 0 1 1 0; 0.5 0.5 0.5 0.5 0.5];
presentZ=[0 0 0 0 0; 0 0 0 0 0; 0.5 0.5 0.5 0.5 0.5; 1 1 1 1 1; 1 1 1 1 1];

%draw some presents with random colors
%scale present and move it to the right place and get the plot handle
myHandle=surf((presentX*scalex+dx),(presentY*scaley+dy), (presentZ*scalez+dz));
%some random color map
randColorMap(:,:,1)=repmat(rand,[5,5]);%r component
randColorMap(:,:,2)=repmat(rand,[5,5]);%g component
randColorMap(:,:,3)=repmat(rand,[5,5]);%b component
%Assign colormap just to the plot handle object of the present, so the tree
%does not change color
set(myHandle,'CData',randColorMap)
shading interp %Nice shding + without grid

end % of function



Sunday, November 25, 2012

Frequency Response Analysis for a Transfer Function

to analysis the frequency response of any transfer function we use FREQS (for analog system or for S-domain) & FREQZ (for digital system or for Z-domain).

Program (for S-domain): 

clear
clc
num=input('enter the coefficient of numerator: ');
den=input('enter the coefficient of denominator: ');
freqs(num,den)

Output:

enter the coefficient of numerator: 1
enter the coefficient of denominator: [1 2 8]

Program (for Z-domain): 

clear
clc
num=input('enter the coefficient of numerator: ');
den=input('enter the coefficient of denominator: ');
freqz(num,den)

Output:

enter the coefficient of numerator: [1 1 2]
enter the coefficient of denominator: [2 1 3]





Thursday, May 17, 2012

Stability of a System Using Routh-Hurwitz Criterion

Stability of any system is an important issue. we have several methods to find out the stability of any system Routh-Hurwitz Criterion is one of them, we can check the stability of system using Routh Matrix.
Routh- Hurwitz Criterion state that "The system is stable if and only if all the elements in the first column have same algebaric sign. If all elements are not of the same sign then the number of sign change of the elements  in first column equals the number of rots of characteristic equation in the right half of S-plane"


Using MATLAB can check the stability of any system on the bases of Routh-Hurwitz Criterion with the help of following program:


%% routh hurwitz criteria
clear
clc
%% firstly it is required to get first two row of routh matrix
e=input('enter the coefficients of characteristic equation: ');
disp('-------------------------------------------------------------------------')
l=length(e);
m=mod(l,2);
if m==0
    a=rand(1,(l/2));
    b=rand(1,(l/2));
    for i=1:(l/2)
        a(i)=e((2*i)-1);
        b(i)=e(2*i);
    end
else
    e1=[e 0];
    a=rand(1,((l+1)/2));
    b=[rand(1,((l-1)/2)),0];
    for i=1:((l+1)/2)
        a(i)=e1((2*i)-1);
        b(i)=e1(2*i);
    end
end
%% now we genrate the remaining rows of routh matrix
l1=length(a);
c=zeros(l,l1);
c(1,:)=a;
c(2,:)=b;
for m=3:l
    for n=1:l1-1
        c(m,n)=-(1/c(m-1,1))*det([c((m-2),1) c((m-2),(n+1));c((m-1),1) c((m-1),(n+1))]);
    end
end
disp('the routh matrix:')
disp(c)
%% now we check the stablity of system
if c(:,1)>0
    disp('System is Stable')
else
    disp('System is Unstable');
end

Note: We can use above program only for normal case.

Friday, December 30, 2011

Programming in MATLAB for Beginners-5

Now move a step ahead towards high level programming in MATLAB:

Is it possible to make large programs & store our codeings on MATLAB?????
Answer is YES........
How???????
with the help of editor
Editors: editors are use for store the cods or set of instructions. we can run our code or program stored in editor any time. editor create a M-File with the extension " .m ".
to open editor just type " edit " on your command window, you will get a new window. 
There are two types of M-File:
  1. Script Files
  2. Function File
Script File: Script files are set of codes & instructions. we can say scripts are simplest kind of M-File. a script file contain a whole as well as a part of any program. we can run any program directly from editor. the output will shown on command window.
to call any script file just type the name of file on command window.

Function File: MATLAB has many inbuilt functions like sin, cos etc. but some time we need a function which is not inbuilt in MATLAB. to create such functions we also use editors. once we create a function, we can call it any time in our program.

always remember the name of any M-File must not be same as any inbuilt function or command in MATLAB.