12. Program 11:
clear all;close all;clc;
t=1:0.1:5;
y=rand(1,length(t));
dy1=diff(y)./diff(t);
td1=t(2:length(t));
subplot 211
plot(t,y)
title('noise signal over 5 second')
subplot 212
plot(td1,dy1)
title('the rate of change of the noise w.r.t
time')
1 1.5 2 2.5 3 3.5 4 4.5 5
0
0.5
1
noise signal over 5 second
1 1.5 2 2.5 3 3.5 4 4.5 5
-10
-5
0
5
10
the rate of change of the noise w.r.t time
13. :12Program
clear all;close all;clc;
x=0:0.1:10;
y=0:0.1:10;
[x1 y1]=meshgrid(x,y);
for i=1:length(x)
for j=1:length(y)
if (y1(i,j)>=0 && y1(i,j)<2)
z1(i,j)=0;
elseif (y1(i,j)>=2 && y1(i,j)<4)
z1(i,j)=2;
elseif (y1(i,j)>=4 && y1(i,j)<6)
z1(i,j)=4;
elseif (y1(i,j)>=6 && y1(i,j)<8)
z1(i,j)=6;
else
z1(i,j)=8;
end
end
end
surf(x1,y1,z1)
0
2
4
6
8
10
0
5
10
0
2
4
6
8