Write a matlab script to substract two given signal.
MATLAB SCRIPT
function [2,N]=Substracting (x,a,x2,b)
x1=input ('enter sequence1');
x2=input ('enter sequence2');
a=input ('a');
b=input ('b');
n11=min(a);
n21=min(b);
n22=max(b):
subplot (2,2,1);
stam (a,x);
x lable ('x-axis');
y lable ('y-axis');
title ('sequence1');
subplot (2,2,1);
stam (b,x2);
x-lable ('x-axis');
y-lable ('y-axis');
title ('sequence');
k=abs(n11)-abs(n21);
p=abs(k);
if(k>0)
x2= [zeros(1,p),x2];
else
x1= [zeros(1,p),x1];
end;
r=abs(s);
if(s>0):
x2=[(x2,zeros(1,r)];
else
x1=[(x1,zeros(1,r)];
end
z=x1+x2;
if[abs(n11) > abs(n21)]
n1=n11;
else
n1=n21;
end
if [abs (n12)> abs(n22)]
n2=n21;
else
n2=n22;
end
n=[n1 n2]
subplot (2,2,3);
stem (n,2);
title ('resultant sequence');
result: they we have done the substract of two discreate signals'
discussions:
1. proper looking of commands should be own
2.put commons & sem collumns at right place
3.no . of divison should be to the graph.
Monday, 28 November 2011
Write a matlab script to add two discreate signal
Write a matlab script to add two discreate signal.
MATLAB SCRIPT
function [2,N]=ADDING (x,a,x2,b)
n1=[3 4 2 1 3]
n2=[1 5 3 6 4 7]
a=[-1:3];
b=[-2:3];
n11=min(a);
n12=max(a):
subplot (2,2,1);
stam (a,x);
title ('sequence1');
n12=min(b);
n22=max(b):
subplot (2,2,2);
stam (b,n2);
title ('sequence1');
k=abs(n11)-abs(n21);
b=abs(k);
if(k>0)
x2= [zeros(1,p),n2];
else
x1= [zeros(1,p),x];
end;
s=abs(n12)-abs(n22);
r=abs(s);
if(s>0):
n2=[(n2,zeros(1,r)];
else
n1=[(n1,zeros(1,r)];
end
z=n1+n2;
if[abs(n11) > abs(n21)]
n1=n11;
else
n1=n21;
end
if [abs (n12)> abs(n22)]
n2=n21;
else
n2=n22;
subplot (2,2,3);
stem (n,2);
title ('resultant sequence');
result: they we have done the addition of two discreate signals'
discussions:
1. proper looking of commands should be own
2.put commons & sem collumns at right place
3.no . of divison should be to the graph.
MATLAB SCRIPT
function [2,N]=ADDING (x,a,x2,b)
n1=[3 4 2 1 3]
n2=[1 5 3 6 4 7]
a=[-1:3];
b=[-2:3];
n11=min(a);
n12=max(a):
subplot (2,2,1);
stam (a,x);
title ('sequence1');
n12=min(b);
n22=max(b):
subplot (2,2,2);
stam (b,n2);
title ('sequence1');
k=abs(n11)-abs(n21);
b=abs(k);
if(k>0)
x2= [zeros(1,p),n2];
else
x1= [zeros(1,p),x];
end;
s=abs(n12)-abs(n22);
r=abs(s);
if(s>0):
n2=[(n2,zeros(1,r)];
else
n1=[(n1,zeros(1,r)];
end
z=n1+n2;
if[abs(n11) > abs(n21)]
n1=n11;
else
n1=n21;
end
if [abs (n12)> abs(n22)]
n2=n21;
else
n2=n22;
subplot (2,2,3);
stem (n,2);
title ('resultant sequence');
result: they we have done the addition of two discreate signals'
discussions:
1. proper looking of commands should be own
2.put commons & sem collumns at right place
3.no . of divison should be to the graph.
Generation Of RAMP function and Discreate
Generation Of RAMP function and Discreate
MATLAB Script
(1)
plot for continuous ramp function
t=-5:0.01:5;
y=t* (t>=0);
plot (t,y);
x lable ('x-axis');
y lable ('y-axis');
title ('plot for continuous ramp function');
(2)
plot for discreate ramp function
t=-5:0.01:5;
y=t* (t>=0);
stem (t,y);
x lable ('x-axis');
y lable ('y-axis');
title ('plot for discreate ramp function');
Result: we have written the progrma for ramp function continuous and descrete signal & obtain tha plotted graph.
Disccussion:
-put ; after each statement
-spelling of each word should be written correctly
-ex potential fignchion is written as -exp(x)
-mention x-axis,y-axis and title of the graph.
MATLAB Script
(1)
plot for continuous ramp function
t=-5:0.01:5;
y=t* (t>=0);
plot (t,y);
x lable ('x-axis');
y lable ('y-axis');
title ('plot for continuous ramp function');
(2)
plot for discreate ramp function
t=-5:0.01:5;
y=t* (t>=0);
stem (t,y);
x lable ('x-axis');
y lable ('y-axis');
title ('plot for discreate ramp function');
Result: we have written the progrma for ramp function continuous and descrete signal & obtain tha plotted graph.
Disccussion:
-put ; after each statement
-spelling of each word should be written correctly
-ex potential fignchion is written as -exp(x)
-mention x-axis,y-axis and title of the graph.
Generation of Continuous and Discrete Unit Step Signal.
Generation of Continuous and Discrete Unit Step Signal.
(1)
plot for continuous unit step signal
t=-5:0.001:5;
y=t>=0;
plot (t,y);
x lable ('x-axis');
y lable ('y-axis');
title ('plot for continuous unit step signal');
(2)
plot for discreate unit step signal
n=-10:1:10
for i=1 length(n)
if n(i)>=0
unit-step (i)=1;
else
unit=step(i)=1;
end
end
stem('n unit=step');
x-lable ('x-axis');
y-lable ('y-axis');
title ('plot for discreate unit step function');
Result: we have written the progrma for generate of unit step function continuous and descrete signal & obtain tha plotted graph.
Disccussion:
-one should know the proper working of commonly
-we should know how to operate computer
-no.of divison should be accroding graph.
(1)
plot for continuous unit step signal
t=-5:0.001:5;
y=t>=0;
plot (t,y);
x lable ('x-axis');
y lable ('y-axis');
title ('plot for continuous unit step signal');
(2)
plot for discreate unit step signal
n=-10:1:10
for i=1 length(n)
if n(i)>=0
unit-step (i)=1;
else
unit=step(i)=1;
end
end
stem('n unit=step');
x-lable ('x-axis');
y-lable ('y-axis');
title ('plot for discreate unit step function');
Result: we have written the progrma for generate of unit step function continuous and descrete signal & obtain tha plotted graph.
Disccussion:
-one should know the proper working of commonly
-we should know how to operate computer
-no.of divison should be accroding graph.
Generation of continuous and discrete elementary signals (periodic and non-periodic) using mathematical expression
MATLAB SCRIPT
plot for continuous periodic signal
y=sine , lim -2pie to 2pie
Program1:
x=line space (-2*pi,2*pi,100);
y=sin(y)
plot(x,y);
x lable ('x-axis');
y lable ('y-axis');
title ('continuous signal for y=sinx);
box on;
*
plot for continuos non-periodic signal
y=eX lim -5 to 5
Progrma-2
x=lim space (-5 to 5,100;
y=(xp,x);
plot (x,y);
x label ('x-axis');
y lable ('y-axis');
title ('plot for continuous non-periodic signal y= ex');
box on;
*
plot for discreate periodic & non-periodic signal periodic->y=sinx=-2pie to 2pie
non-periodic -> t=eq, a=-5 to 5
x=line space (-2*pi,2*pi,100);
y=sinx;
supplot(2,1,1);
stem(x,y);
x-lable('x-axis');
y-lable('y-axis');
title('plot for discreate periodic signal');
a=linespace(-5,5,100);
t=(xp.(a));
subplot(2,1,2);
stem(a,t);
x-lable('x-axis');
y-lable('y-axis');
title ('plot for discreate periodic & non-periodic signal');
Result: we have written the progrma for periodic & non-periodic signal & obtain tha plotted graph.
precautions:
put ; after each statement
spelling of each word should be written correctly
ex-line space
-ex potential fignchion is written as -exp(x)
-mention x-axis,y-axis and title of the graph.
plot for continuous periodic signal
y=sine , lim -2pie to 2pie
Program1:
x=line space (-2*pi,2*pi,100);
y=sin(y)
plot(x,y);
x lable ('x-axis');
y lable ('y-axis');
title ('continuous signal for y=sinx);
box on;
*
plot for continuos non-periodic signal
y=eX lim -5 to 5
Progrma-2
x=lim space (-5 to 5,100;
y=(xp,x);
plot (x,y);
x label ('x-axis');
y lable ('y-axis');
title ('plot for continuous non-periodic signal y= ex');
box on;
*
plot for discreate periodic & non-periodic signal periodic->y=sinx=-2pie to 2pie
non-periodic -> t=eq, a=-5 to 5
x=line space (-2*pi,2*pi,100);
y=sinx;
supplot(2,1,1);
stem(x,y);
x-lable('x-axis');
y-lable('y-axis');
title('plot for discreate periodic signal');
a=linespace(-5,5,100);
t=(xp.(a));
subplot(2,1,2);
stem(a,t);
x-lable('x-axis');
y-lable('y-axis');
title ('plot for discreate periodic & non-periodic signal');
Result: we have written the progrma for periodic & non-periodic signal & obtain tha plotted graph.
precautions:
put ; after each statement
spelling of each word should be written correctly
ex-line space
-ex potential fignchion is written as -exp(x)
-mention x-axis,y-axis and title of the graph.
Subscribe to:
Posts (Atom)