星期三, 9月 23, 2009

【matlab】 090924work

matlab work2

% program file lab092401.m
clear all;

dt = 0.01;
w = 2;
a = 10;
k = 0;
for t = -10:dt:10
k = k+1;
x(1,k) = a * cos(w*t);
end
tt = -10:dt:10;
plot(tt,x);

% t = -10:dt:10;
% a = 10;
% x = a * cos(w*t);
% plot(t,x);

xlabel('t,(s)');
ylabel('x(t)');
grid;



% program file lab092402.m
dt = 0.01;
w = 2;
t = -10:dt:10;
a = 10;
x1 = a * cos(w*t);
td = -0.5;
x2 = a * cos(w*(t+td));
subplot(211);
plot(t,x1);
xlabel('t,(s)');
ylabel('x(t)');
grid;

subplot(212);
plot(t,x2);

xlabel('t,(s)');
ylabel('x(t)');
grid;



% program file lab092403.m
clear all;
dt = 0.01;
w = 2;
t = -10:dt:10;
a = 10;
x1 = a * cos(w*t);
td = -0.5;
x2 = a * cos(w*(t+td));

subplot(311);
plot(t,x1);
xlabel('t,(s)');
ylabel('x(t)');
grid;

subplot(312);
plot(t,x2);
xlabel('t,(s)');
ylabel('x(t)');
grid;

subplot(313);
%figure(2);
plot(t,x1,'r');
hold on;
plot(t,x2,'g');
xlabel('t,(s)');
ylabel('x(t)');
grid;

沒有留言: