10
%-- 6/12/2013 7:12 AM --% x=0:0.1:1; y=10*exp(-t/0.1) y=10*exp(-x/0.1) plot(x,y) x=0:0.01:1; plot(x,y) y x=0:0.01:1; y=10*exp(-x/0.1) plot(x,y) num=[1]; den=[0.1 1]; sys=tf(num, den) impulse(sys) axis[0 1 0 11] num=[1]; den=[0.1 1]; sys=tf(num, den) impulse(sys) axis([0 1 0 11]) x=0:0.001:1; y=10*exp(-x/0.1); plot(x,y) %-- 6/12/2013 8:05 PM --% num=[1]; den=[0.1 1]; sys=tf(num, den) impulse(sys) axis([0 1 0 11]) x=0:0.001:1; y=10*exp(-x/0.1); plot(x,y) step(sys) axis([0 1 0 11]) axis([0 1 0 1]) %-- 6/12/2013 9:35 PM --% num=[1]; den=[0.1 1]; sys=tf(num, den) axis[0 1 0 1] step(sys) axis([0 1 0 1]) num=[1]; den=[0.1 1]; sys=tf(num, den) step(sys)

matlab codes

  • Upload
    ims1988

  • View
    10

  • Download
    0

Embed Size (px)

DESCRIPTION

matlab codes

Citation preview

Page 1: matlab codes

%-- 6/12/2013 7:12 AM --%x=0:0.1:1;y=10*exp(-t/0.1)y=10*exp(-x/0.1)plot(x,y)x=0:0.01:1;plot(x,y)yx=0:0.01:1;y=10*exp(-x/0.1)plot(x,y)num=[1];den=[0.1 1];sys=tf(num, den)impulse(sys)axis[0 1 0 11]num=[1];den=[0.1 1];sys=tf(num, den)impulse(sys)axis([0 1 0 11])x=0:0.001:1;y=10*exp(-x/0.1);plot(x,y)%-- 6/12/2013 8:05 PM --%num=[1];den=[0.1 1];sys=tf(num, den)impulse(sys)axis([0 1 0 11])x=0:0.001:1;y=10*exp(-x/0.1);plot(x,y)step(sys)axis([0 1 0 11])axis([0 1 0 1])%-- 6/12/2013 9:35 PM --%num=[1];den=[0.1 1];sys=tf(num, den)axis[0 1 0 1]step(sys)axis([0 1 0 1])num=[1];den=[0.1 1];sys=tf(num, den)step(sys)axis([0 1 0 1])syms sf=(1/s*(1+0.1*s));ilaplace(f)y=ilaplace(f)x=0:0.001:1;plot(x,y)y=ilaplace(f)plot(x,y)

Page 2: matlab codes

axis([0 1 0 1])plot(x,y)axis([0 1 0 1])t=0:0.001:1;plot(y, t)syms silaplace(1/s)plot(1-exp(-x/0.1))plot(r(t))a=(1-exp(-x/0.1))a=(1-exp(-x/0.1));num=[1];den=[0.1 1];sys=tf(num, den)b=step(sys)plot(a,b)axis([0 1 0 1])plot(a,b)axis([0 1 0 1])a=(1-exp(-x/0.1));b=step(sys)plot(a,b)step(sys:1)axis([0 1 0 1])x=0:0.001:1;plot(1-exp(-x/0.1));axis([0 1 0 1])a=exp(-x/0.1)x=0:0.001:1;a=exp(-x/0.1);b=step(1);plot(1-a);ilaplace(1/(s*(1+0.1*s)))y=ilaplace(1/(s*(1+0.1*s)));plot(x,y);axis([0 1 0 1])plot(ilaplace(1/(s*(1+0.1*s))),x)ilaplace(1/(s*(1+0.1*s)))axis=([0 1 0 1])y=ilaplace(1/(s*(1+0.1*s)));plot(y)%-- 6/12/2013 11:26 PM --%y=ilaplace(1/(s*(1+0.1*s)));syms sy=ilaplace(1/(s*(1+0.1*s)));y(1)y(2)%-- 6/12/2013 11:54 PM --%num=[1];den=[0.1 1];sys=tf(num, den)axis([0 1 0 1])t=0:0.05:1;tur=t;our=lsim(sys,tur,t);plot(t,our);

Page 3: matlab codes

t=0:0.05:1;tua=t*t/2;num=[1];den=[0.1 1];sys=tf(num, den)t=0:0.05:1;tua=t.*t/2;oua=lsim(sys,tua,t);plot(t,oua);axis([0 1 0 1])axis([0 1 0 0.5])%-- 6/13/2013 8:56 AM --%y=1-(exp(-10*t)):y=(1-(exp(-10*t))):y=1-(exp(-10*t));t= 0:0.0001:1:t= 0:0.0001:1;y=1-(exp(-10*t));plot(y,t);plot(t,y);t=0:0.0001:1;y=1-exp(10*t);plot(t,y);t=0:0.0001:1;y=1-exp(-10*t);plot(t,y);%-- 6/13/2013 9:42 AM --%t=0:0.0001:1;y=1-exp(-10*t);plot(t,y);%-- 6/13/2013 10:11 AM --%t=0:0.0001:1;y=1-exp(-10*t);plot(t,y);y1= t-0.1-0.1*exp(-10*t);plot(t,y1);t=0:0.0001:1;y1= t-0.1+0.1*exp(-10*t);plot(y1,t);y2= t+0.1*exp(-10*t);plot(t,y1,t,y2);t=0:0.0001:1;y1= t-0.1+0.1*exp(-10*t);plot(t,y1);y2=t^2/2-0.1*t+ 0.01- 0.01*exp(-10t);t=0:0.0001:1;y2=(t^2/2)-(0.1*t)+ 0.01- (0.01*exp(-10t));y2=((t^2/2)-(0.1*t)+ 0.01- (0.01*exp(-10t)));t=0:0.0001:1;y1=t^2/2;t=0:0.0001:1;y2=((t.^2/2)-(0.1*t)+ 0.01- (0.01*exp(-10t)));y2=(t.^2/2)-(0.1*t)t=0:0.0001:1;y2=(t.^2/2)-(0.1*t);y2=((t.^2/2)-(0.1*t)+ 0.01;

Page 4: matlab codes

y2=(t.^2/2)-(0.1*t)+ 0.01;y2=((t.^2/2)-(0.1*t)+ 0.01- (0.01*exp(-10*t)));t=0:0.0001:1;y2=((t.^2/2)-(0.1*t)+ 0.01- (0.01*exp(-10*t)));plot(t,y2);%-- 8/8/2013 6:05 AM --%%-- 8/21/2013 4:41 PM --%%-- 8/21/2013 5:51 PM --%identfilename='control system.xisx';sheet=1;xlRange='A1:B51';subsetA = xlsread(filename, sheet, xlRange)filename='control system.xisx';sheet=1;xlRange='A1:B51';subsetA = xlsread(filename, sheet, xlRange)(num,txt,raw)= xlsread(filename, sheet, xlRange)xlsread[num,txt,raw]= xlsread(filename, sheet, xlRange)filename='control system.xisx';sheet=1;xlRange='A1:B51';[num,txt,raw]= xlsread(filename, sheet, xlRange)a=xlsread(filename)filename='aadata.xisx';A=xlsread(filename)help xlsread[NUM,TXT,RAW]=xlsread(FILE,SHEET,RANGE)file='aadata.xisx'A=xlsread(file);file='H:\AA\control system.xisx';A=xlsread(file);[fname,fpath] = uigetfile({'aadata.xls';'aadata.xlsx'});if fpath==0, error('no file selected'); end[num,txt,raw] = xlsread( fullfile(fpath,fname) );[fname,fpath] = uigetfile({'aadata.xls';'aadata.xlsx'});if fpath==0, error('no file selected'); end[num,txt,raw] = xlsread( fullfile(fpath,fname) );numpolyfit(num)%-- 8/28/2013 9:34 PM --%%-- 8/29/2013 10:29 AM --%cftoolt= xlsread('C:\dataCS','A2:A52')y= xlsread('C:\dataCS','B2:B52')plot(x,y);plot(x,y)plot(t,y);t= xlsread('C:\dataCS','A2:A52')y= xlsread('C:\dataCS','B2:B52')plot(t,y);xlabel('time');ylabel('output');%-- 8/29/2013 11:34 AM --%y= xlsread('C:\dataCS','B2:B52')

Page 5: matlab codes

t= xlsread('C:\dataCS','A2:A52')plot(t,y);xlabel('time');ylabel('output');laplace(fit)y = - 5.334e-06*x^{4} + 0.000906*x^{3} - 0.05792*x^{2} + 1.68*x - 0.9711x=t;y = - 5.334e-06*x^{4} + 0.000906*x^{3} - 0.05792*x^{2} + 1.68*x - 0.9711y = - 5.334e-06*t^{4} + 0.000906*t^{3} - 0.05792*t^{2} + 1.68*t - 0.9711laplace( - 5.334e-06*t^{4} + 0.000906*t^{3} - 0.05792*t^{2} + 1.68*t - 0.9711);help laplacelookfor laplacelapalcesyms x;f = - 5.334e-06*t^{4} + 0.000906*t^{3} - 0.05792*t^{2} + 1.68*t - 0.9711f = - 5.334e-06*t^{4} + 0.000906*t^{3} - 0.05792*t^{2} + 1.68*t - 0.9711;z=- 5.334e-06;f = z*t^{4} + 0.000906*t^{3} - 0.05792*t^{2} + 1.68*t - 0.9711;syms t;f = z*t^{4} + 0.000906*t^{3} - 0.05792*t^{2} + 1.68*t - 0.9711;f = z*.t^{4} + 0.000906*.t^{3} - 0.05792*.t^{2} + 1.68*.t - 0.9711;f = - 5.334e-06*t^{4} + 0.000906*t^{3} - 0.05792*t^{2} + 1.68*t - 0.9711;f = - 5.334e-06*t^{4} + 0.000906*t^{3} - 0.05792*t^{2} + 1.68*t - 0.9711f =( - 5.334e-06)*t^{4} + (0.000906)*t^{3} - (0.05792)*t^{2} + (1.68)*t - (0.9711;f =( - 5.334e-06)*t^{4} + (0.000906)*t^{3} - (0.05792)*t^{2} + (1.68)*t - 0.9711;syms a;f= - 5.334e-06*a^{4} + 0.000906*a^{3} - 0.05792*a^{2} + 1.68*a - 0.9711;%-- 8/29/2013 1:12 PM --%y= xlsread('C:\dataCS','B2:B52');t= xlsread('C:\dataCS','A2:A52')plot(t,y);xlabel('time');ylabel('output');syms t sf= 2.056e-13*t^{10} - 5.568e-11*t^{9} + 6.515e-09*t^{8} - 4.313e-07*t^{7} + 1.778e-05*t^{6} - 0.0004723*t^{5} +0.008088*t^{4} - 0.0855*t^{3} + 0.4678*t^{2} + 0.2118*t - 0.03197;f= 2.056e-13*t^{10} - 5.568e-11*t^{9} + 6.515e-09*t^{8} - 4.313e-07*t^{7} + 1.778e-05*t^{6} - 0.0004723*t^{5} +0.008088*t^{4} - 0.0855*t^{3} + 0.4678*t^{2} + 0.2118*t - 0.03197;2.056*10^(-13)*t^{10} - 5.568*10^(-11)*t^{9} + 6.515*10^(-9)*t^{8} - 4.313*10^(-7)*t^{7} + 1.778*10^(-5)*t^{6} - 0.0004723*t^{5} +0.008088*t^{4} - 0.0855*t^{3} + 0.4678*t^{2} + 0.2118*t - 0.03197;syms x sf=2.056e-13*x^{10} - 5.568e-11*x^{9} + 6.515e-09*x^{8} - 4.313e-07*x^{7} + 1.778e-05*x^{6} - 0.0004723*x^{5} + 0.008088*x^{4} - 0.0855*x^{3} + 0.4678*x^{2} + 0.2118*x - 0.03197;f=2t;f=2*t;laplace(f)f= 2.056*10^(-13)*t^{10} - 5.568*10^(-11)*t^{9} + 6.515*10^(-9)*t^{8} - 4.313*10^(-7)*t^{7} + 1.778*10^(-5)*t^{6} - 0.0004723*t^{5} +0.008088*t^{4} - 0.0855*t^{3} + 0.4678*t^{2} + 0.2118*t - 0.03197;f= 2.056*10^(-13)*t^{10f= 2.056*10^(-13)*t^{10);f= 2.056e-13)*t^{10);f= 2.056e-13*t^{10);syms t s

Page 6: matlab codes

f=-1.25+3.5*t*exp(-2*t)+1.25*exp(-2*t);F=laplace(f,t,s)syms t sf=2.056e-13*x^{10};syms t sf=2.056*(10^(-3))*x^{10};f=2.056*(10^(-3))*t^{10};syms t sf=2.056*(10^(-3))*t^{10};a=2.056*(10^(-3);a=2.056*10^(-3);syms t sf=a.*t^{10};f=a*.t^{10};fitfit1laplace(fit1);coefffit1syms x slaplace(fit1);laplace(fit1)syms t sf=fit1;F=laplace(f);syms t slaplace(t^10)laplace(1.2*10^(-3)*t)laplace(1.2*10^(-3)*t^(3))laplace(2.056*10^(-3)*t^(3))laplace((2.056*10^(-3))*t^(3))laplace( 2.056*10^(-13)*t^{10} - 5.568*10^(-11)*t^{9} + 6.515*10^(-9)*t^{8} - 4.313*10^(-7)*t^{7} + 1.778*10^(-5)*t^{6} - 0.0004723*t^{5} +0.008088*t^{4} - 0.0855*t^{3} + 0.4678*t^{2} + 0.2118*t - 0.03197)a=2.056*10^(-13)*t^{10}laplace( 2.056*10^(-13)*t^(10) - 5.568*10^(-11)*t^(9) + 6.515*10^(-9)*t^(8) - 4.313*10^(-7)*t^(7) + 1.778*10^(-5)*t^(6) - 0.0004723*t^(5) +0.008088*t^(4) - 0.0855*t^(3) + 0.4678*t^(2) + 0.2118*t - 0.03197)identtf= s.ansF= laplace( 2.056*10^(-13)*t^(10) - 5.568*10^(-11)*t^(9) + 6.515*10^(-9)*t^(8) - 4.313*10^(-7)*t^(7) + 1.778*10^(-5)*t^(6) - 0.0004723*t^(5) +0.008088*t^(4) - 0.0855*t^(3) + 0.4678*t^(2) + 0.2118*t - 0.03197);tf= s.*Flaplace( 2.056*10^(-13)*t^(10) - 5.568*10^(-11)*t^(9) + 6.515*10^(-9)*t^(8) - 4.313*10^(-7)*t^(7) + 1.778*10^(-5)*t^(6) - 0.0004723*t^(5) +0.008088*t^(4) - 0.0855*t^(3) + 0.4678*t^(2) + 0.2118*t - 0.03197)F= laplace( 2.056*10^(-13)*t^(10) - 5.568*10^(-11)*t^(9) + 6.515*10^(-9)*t^(8) - 4.313*10^(-7)*t^(7) + 1.778*10^(-5)*t^(6) - 0.0004723*t^(5) +0.008088*t^(4) - 0.0855*t^(3) + 0.4678*t^(2) + 0.2118*t - 0.03197);tf= s.*Ft= xlsread('C:\dataCS','A2:A52')identsys=tfstep(sys)ident

Page 7: matlab codes

t= xlsread('C:\dataCS','A2:A52')y= xlsread('C:\dataCS','B2:B52');identt= xlsread('C:\dataCS','A2:A52');y= xlsread('C:\dataCS','B2:B52');ident%-- 8/29/2013 5:25 PM --%%-- 8/29/2013 6:07 PM --%y= xlsread('C:\dataCS','B2:B52');t= xlsread('C:\dataCS','A2:A52');plot(t,y);ident%-- 8/29/2013 9:05 PM --%y= xlsread('C:\dataCS','B2:B52');t= xlsread('C:\dataCS','A2:A52');ident%-- 9/10/2013 6:58 AM --%%-- 11/8/2013 5:13 PM --%info=imaqhwinfo('winvideo')info.DeviceInfo(1)info.DeviceInfo.SupportedFormatsvid=videoinput('winvideo',3)vid=videoinput('winvideo',1)preview(vid)s=getsnapshot(vid)image(s)redObjectTrack%-- 11/13/2013 3:30 PM --%main%-- 11/13/2013 3:32 PM --%close allclear allim1=imread('K.bmp');im1=imread('K.JPEG')CDcdcd G;cd G:\.%-- 11/13/2013 3:41 PM --%cdcd G:\.imread('K')imread('K.jpg')cd G:\.imread('K.jpg');imread('letters.jpg');function result=tmp(image1,image2);result1=tmp(im1,im2);im1=imread('K.jpg');im2=imread('letters.jpg');result1=tmp(im1,im2);figure,subplot(2,2,1),imshow(im1);title('Template');subplot(2,2,2),imshow(im2);title('Target');subplot(2,2,3),imshow(result1);title('Matching Result using tmp');result2=tmc(im1,im2);

Page 8: matlab codes

figure,subplot(2,2,1),imshow(im1);title('Template');subplot(2,2,2),imshow(im2);title('Target');subplot(2,2,3),imshow(result2);title('Matching Result using tmc');clear allclose allclccd G:\.letter=imread('K.jpg');[rowlet,collet]=size(letter);sprintf('The size of the letter is %dx%d',rowlet,collet)GrpOfLetters=imread('letters.jpg');[rowGrp,colGrp]=size(GrpOfLetters);sprintf('The size of Group of letters is %dx%d',rowGrp,colGrp)imshow(letter).title('Single letter')imshow(letter);imshow(letter),title('Single letter');imshow(GrpOfLetter),title('Group of letters');imshow(GrpOfLetters),title('Group of letters');cc=normxcorr2(letter,GrpOfLetters);cc = normxcorr2(letter,GrpOfletters);cc = normxcorr2(letter,GrpOfLetters);cc = normxcorr2(letter,GrpOfLetters)cc = normxcorr2(letter, GrpOfLetters);help normxcorr2cc = normxcorr2(letter, GrpOfLetters);c = normxcorr2(letter, GrpOfLetters);I = .2*ones(11); % make light gray plus on dark gray backgroundI(6,3:9) = .6;I(3:9,6) = .6;BW = I>0.5; % make white plus on black backgroundimshow(I,'n'), figure, imshow(BW,'n')norm_xcorr_II = normxcorr2(I,I); % cross-correlate with selfnorm_xcorr_BWI = normxcorr2(BW,I); % cross-correlate with BWfigure, imshow(norm_xcorr_II,'n')figure, imshow(norm_xcorr_BWI,'n')diff_xcorr = norm_xcorr_II - norm_xcorr_BWI;max(diff_xcorr(:)) % Note: maximum difference is within roundoffI = .2*ones(11);I(6,3:9) = .6;I(3:9,6) = .6;BW = I>0.5;imshow(I,'n'), figure, imshow(BW,'n')norm_xcorr_II = normxcorr2(I,I);imshow(I,'n'), figure, imshow(BW,'n');%-- 11/20/2013 5:38 PM --%