% program file w1_20091203.m
clear all;
close all;
x_n = [2 1 1/2 1/4];
nx = [-1 0 1 2];
h_n = [1 1 1 1 ];
nh = [0 1 2 3];
y_n = conv(x_n,h_n);
y_n2 = conv(h_n,x_n);
n0 = nx(1) + nh(1);
N = length(nx)+length(nh)-1;
n = n0:n0 + N-1;
subplot(211);
stem(n,y_n,'b');
grid;
subplot(212);
stem(n,y_n2,'r');
grid;
星期三, 12月 02, 2009
matlab 2009 12/03 w01
matlab 2009 12/03 w01
% program file w1_20091203.m
clear all;
close all;
n_x = [2 1 1/2 1/4];
nx = [-1 0 1 2];
h_n = [1 1 1 1 ];
nh = [0 1 2 3];
y_n = conv(n_x,h_n);
n0 = nx(1) + nh(1);
N = length(nx)+length(nh)-1;
n = n0:n0 + N-1;
subplot(111);
stem(n,y_n,'b');
grid;
星期三, 11月 18, 2009
matlab 2009 11/19 02
% program file lab20091119w1.m
clear all;
clf;
x_n = 10*ones(1,800);
r = 2;
l = 1;
ts = 0.01;
a = [1/ts + r/l -1/ts];
b = [1/l];
y_n = filter(b,a,x_n);
n = 0:1:800-1;
l2= 5;
a2 = [1/ts + r/l2 -1/ts];
b2 = [1/l2];
y2_n = filter(b2,a2,x_n);
x2_n = 10*(n>=50);
y2_n = filter(b2,a2,x2_n);
subplot(211);
stem(n,x2_n,'b');
grid;
subplot(212);
stem(n,y2_n,'b');
grid;
matlab 2009 11/19 01
% program file lab20091119w1.m
clear all;
clf;
x_n = 10*ones(1,400);
r = 2;
l = 1;
ts = 0.01;
a = [1/ts + r/l -1/ts];
b = [1/l];
y_n = filter(b,a,x_n);
n = 0:1:400-1;
subplot(211);
stem(n,x_n,'b');
grid;
subplot(212);
stem(n,y_n,'b');
grid;
星期四, 10月 29, 2009
matlab 2009 10/29 02
% program file lab2009102901.m
clear all;
clf;
tf = 1;
dt = 0.01;
t =0:dt:1;
x1 = cos(2*pi*10*t);
x2 = cos(2*pi*35*t);
fs1 = 2*35;
xc = x1+x2;
ts1 = 1/fs1;
n1 = 0/ts1:1:tf/ts1;
x1_n = cos(2*pi*10*ts1)+cos(2*pi*35*n1*ts1);
subplot(411);
plot(t,x1,'r');
grid;
subplot(412);
plot(t,x2,'g');
grid;
subplot(413);
plot(t,xc,'g');
grid;
subplot(414);
stem(n1,x1_n,'b');
matlab 2009 10 29 01
% program file lab2009102901.m
clear all;
clf;
dt = 0.01;
t =0:dt:5;
x1 = cos(2*pi*10*t);
x2 = cos(2*pi*35*t);
subplot(311);
plot(t,x1,'r');
subplot(312);
plot(t,x2,'g');
subplot(313);
%stem(n,x_n,'b');
星期四, 10月 22, 2009
matlab 2009 10 22 02
% program file lab2009102202.m
clear all;
% clf;
dt = 0.0001;
t =-0.01:dt:0.02;
xc = cos(2*pi*100*t);
tt = 0.0005;
ts = -0.01:tt:0.02;
xd = cos(2*pi*100*ts);
n=-20:1:40;
x4 = cos(2*pi*100*n*tt);
figure(1);
subplot(311);
plot(t,xc);
subplot(312);
stem(ts,xd);
subplot(313);
stem(n,x4);
星期三, 10月 21, 2009
matlab 2009 10 22 01
% program file lab2009102201.m
clear all;
clf;
dt = 0.001;
t =-0:dt:0.1;
s = 5+4*cos(2*pi*20*t);
xc1 = cos(2*pi*200*t);
x1 = s.*xc1;
xc2 = cos(2*pi*700*t);
x2 = s.*xc2;
figure(1);
subplot(311);
plot(t,s,'x');grid;hold on;
plot(t,xc1,'g');
subplot(312);
plot(t,x1);
subplot(313);
plot(t,x2);
星期一, 10月 19, 2009
8051 w2
#pragma oe db pw(80) SM SB CD
#include
#include "Delay.h"
main(){
int num = 0;
char State=0;
P2 =0x3f;
for(;num<6;){
Delay1s();
if(State == 1){
P2 <<= 1;
P2 |=0x01;
}
if(State == 0){
P2 >>= 1;
P2 |=0x80;
}
if((P2&0xc0)==0){//0011 1111 + 1100 0000 =0
State= 0;
num++;
}
if((P2&0x03)==0){
State= 1;
num++;
}
}
for(;;);
}
8051 w2
#pragma oe db pw(80) SM SB CD
#include
#include "Delay.h"
main(){
int num = 0;
char State=0;
P2 =0x3f;
for(;num<6;){
Delay1s();
if(State == 1){
P2 <<= 1;
P2 |=0x01;
}
if(State == 0){
P2 >>= 1;
P2 |=0x80;
}
if((P2&0xc0)==0){//0011 1111 + 1100 0000 =0
State= 0;
num++;
}
if((P2&0x03)==0){
State= 1;
num++;
}
}
for(;;);
}
8051 led2
#pragma oe db pw(80) SM SB CD
#include
void Delay1s(void){ //時間延遲一秒的函數
ACC = 5;
F0 = 1;
F0 = 1;
F0 = 1;
}
main(){
int num = 0; //宣告用來表示次數的變數
char State=0; //宣告檢測右邊和左邊的變數
P0 =0xc0; //初始設定左邊2個點燈是亮的
for(;num<6;){ //來回跑3次的設定
Delay1s(); //時間暫停一秒
if(State == 0) P0 >>= 1; //當電燈到達左邊2個發光時,開始向右邊跑
if(State == 1) P0 <<= 1; //當電燈到達右邊2個發光時,開始向左邊跑
if((P0&0x3f)==0){ //當電燈到達左邊時
State= 0; //檢測變數會改變為 左
num++; //開始算一次
}
if((P0&0xfc)==0){ //當電燈到達右邊
State= 1; //檢測變數會改變為 右
num++; //開始算一次
}
}
for(;;);//讓程式進入無限回圈
}
星期三, 10月 14, 2009
matlab 2009101501
% program file lab2009101501.m
clear all;
t = -0.05:0.001:0.05;
x1 = 10;
x2 = 14*cos(2*pi*100*t-pi/3);
x3 = 8*cos(2*pi*250*t+pi/2);
x4 = x1 + x2 + x3;
subplot(411);
plot(t,x1);
subplot(412);
plot(t,x2);
subplot(413);
plot(t,x3);
subplot(414);
plot(t,x4);
星期二, 10月 13, 2009
8051 led
#pragma oe db pw(80) SM SB CD
#include
#include "Delay.h"
code tbl1[]= { 0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf } ;
int num= 0;
int main()
{
char i ;
int id = 0;
/*P0 =0x01;*/
P0 =0xc0;
/*P0 =0x80;*/
for(num = 0;num<=6;){
Delay100ms() ;
P3 = num;
if((P0&0x3f) == 0){ /*0x01*/
num++;
id = 1;
}
if((P0&0xfc) == 0){ /*0x80*/
num++;
id = 0;
}
if(id == 0){
P0 <<=1 ;
}else{
if(num<6) P0 >>=1 ;
}
}
Delay1s() ;
Delay1s() ;
Delay1s() ;
Delay1s() ;
/*P0 >>=1;*/
/*P0=tbl1[1];*/
/*
for(;;) {
for(i = 0 ; i < 14 ; i++ ){
P0=tbl1[i] ;
Delay100ms() ;
}
}
*/
return 0;
}
星期四, 10月 08, 2009
matlab lab 20091008 1
% program file lab200910081.m
clear all;
k = 0;
tt = 0:0.01:10;
for t=0:0.01:10
k = k + 1;
x1(1,k) = cos(2*pi*0.5*t);
x2(1,k) = sin(2*pi*5*t);
x3(1,k) = x1(1,k)*x2(1,k);
end
subplot(311);
plot(tt,x1);
xlabel('t,(s)');
ylabel('x(t)');
grid;
subplot(312);
plot(tt,x2);
xlabel('t,(s)');
ylabel('x(t)');
grid;
subplot(313);
plot(tt,x3);
xlabel('t,(s)');
ylabel('x(t)');
grid;
星期三, 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;
訂閱:
文章 (Atom)