time shifting
i want the program to advance or delay the signal…
by taking input from user whether to advance or delay & by what number?….
please use switch statement?….
any signal like-ramp,step,exponential
in it i am using subplot to plot the original signal & shifted version of the signal..
i have a program something like this–
*clear all
close all
clc
disp(‘given function is’)
x=(-10:10);
for i=1:1:21
if(x(i)>0)
y(i)=exp(x(i));
else
y(i)=0;
end
end
subplot(1,2,1)
stem(x,y)
disp(‘enter whether to advance or delay’)
s=input(‘1>advancen 2>Delay’)
n=input(‘enter the no of step by which signal is to be shifted’)
switch(s)
case 1
[
for i=1+n:1:21+n
if(x(i)>0)
y(i)=1;
else
y(i)=0;
end
]
case 2
[
for i=1-n:1:21-n
if(x(i)>0)
y(i)=1;
else
y(i)=0;
end
]
subplot(1,2,2)
stem(x,y)
but when i run the program it gives error in the ‘for’ command in case 1.i want the program to advance or delay the signal…
by taking input from user whether to advance or delay & by what number?….
please use switch statement?….
any signal like-ramp,step,exponential
in it i am using subplot to plot the original signal & shifted version of the signal..
i have a program something like this–
*clear all
close all
clc
disp(‘given function is’)
x=(-10:10);
for i=1:1:21
if(x(i)>0)
y(i)=exp(x(i));
else
y(i)=0;
end
end
subplot(1,2,1)
stem(x,y)
disp(‘enter whether to advance or delay’)
s=input(‘1>advancen 2>Delay’)
n=input(‘enter the no of step by which signal is to be shifted’)
switch(s)
case 1
[
for i=1+n:1:21+n
if(x(i)>0)
y(i)=1;
else
y(i)=0;
end
]
case 2
[
for i=1-n:1:21-n
if(x(i)>0)
y(i)=1;
else
y(i)=0;
end
]
subplot(1,2,2)
stem(x,y)
but when i run the program it gives error in the ‘for’ command in case 1. i want the program to advance or delay the signal…
by taking input from user whether to advance or delay & by what number?….
please use switch statement?….
any signal like-ramp,step,exponential
in it i am using subplot to plot the original signal & shifted version of the signal..
i have a program something like this–
*clear all
close all
clc
disp(‘given function is’)
x=(-10:10);
for i=1:1:21
if(x(i)>0)
y(i)=exp(x(i));
else
y(i)=0;
end
end
subplot(1,2,1)
stem(x,y)
disp(‘enter whether to advance or delay’)
s=input(‘1>advancen 2>Delay’)
n=input(‘enter the no of step by which signal is to be shifted’)
switch(s)
case 1
[
for i=1+n:1:21+n
if(x(i)>0)
y(i)=1;
else
y(i)=0;
end
]
case 2
[
for i=1-n:1:21-n
if(x(i)>0)
y(i)=1;
else
y(i)=0;
end
]
subplot(1,2,2)
stem(x,y)
but when i run the program it gives error in the ‘for’ command in case 1. switch, homework MATLAB Answers — New Questions