From 49047b316d687fe1ab3d84d40e51bb874696a34e Mon Sep 17 00:00:00 2001 From: bisnsh Date: Fri, 10 Oct 2025 17:29:33 +0800 Subject: [PATCH] Initial commit --- A01.m | 10 ++++++++++ A02.m | 6 ++++++ A03.m | 14 ++++++++++++++ c5_5_3.m | 6 ++++++ c5_5_6.m | 10 ++++++++++ c5_5_7.m | 4 ++++ c5_5_9.m | 10 ++++++++++ c_5_5_5.m | 22 ++++++++++++++++++++++ ctr.m | 11 +++++++++++ ctr.mat | Bin 0 -> 324 bytes deg2rad.m | 9 +++++++++ det_learn.m | 3 +++ diag_learn.m | 3 +++ example1.m | 2 ++ example2.m | 4 ++++ exch.m | 6 ++++++ foo.m | 4 ++++ gridbearing.m | 7 +++++++ ifelse.m | 15 +++++++++++++++ ifelse2.m | 10 ++++++++++ inv_learn.m | 9 +++++++++ leica2.m | 10 ++++++++++ leica3.m | 9 +++++++++ leika.m | 4 ++++ leika.txt | 6 ++++++ magic5.dat | Bin 0 -> 100 bytes matlab.mat | Bin 0 -> 218 bytes newafile.m | 3 +++ nikon.m | 14 ++++++++++++++ nikon.txt | 7 +++++++ plot04.m | 2 ++ plot_learn.m | 3 +++ plotxy01.m | 3 +++ plotxy02.m | 3 +++ plotxy03.m | 2 ++ plotxy08.m | 4 ++++ plotxy09.m | 3 +++ plotxy10.m | 4 ++++ price.m | 15 +++++++++++++++ raddeg.m | 9 +++++++++ rtod.m | 7 +++++++ string_learning.m | 18 ++++++++++++++++++ stringfind.m | 2 ++ structdata.m | 11 +++++++++++ sum_n.m | 9 +++++++++ tran.m | 3 +++ tyrcaatch.m | 7 +++++++ 47 files changed, 323 insertions(+) create mode 100644 A01.m create mode 100644 A02.m create mode 100644 A03.m create mode 100644 c5_5_3.m create mode 100644 c5_5_6.m create mode 100644 c5_5_7.m create mode 100644 c5_5_9.m create mode 100644 c_5_5_5.m create mode 100644 ctr.m create mode 100644 ctr.mat create mode 100644 deg2rad.m create mode 100644 det_learn.m create mode 100644 diag_learn.m create mode 100644 example1.m create mode 100644 example2.m create mode 100644 exch.m create mode 100644 foo.m create mode 100644 gridbearing.m create mode 100644 ifelse.m create mode 100644 ifelse2.m create mode 100644 inv_learn.m create mode 100644 leica2.m create mode 100644 leica3.m create mode 100644 leika.m create mode 100644 leika.txt create mode 100644 magic5.dat create mode 100644 matlab.mat create mode 100644 newafile.m create mode 100644 nikon.m create mode 100644 nikon.txt create mode 100644 plot04.m create mode 100644 plot_learn.m create mode 100644 plotxy01.m create mode 100644 plotxy02.m create mode 100644 plotxy03.m create mode 100644 plotxy08.m create mode 100644 plotxy09.m create mode 100644 plotxy10.m create mode 100644 price.m create mode 100644 raddeg.m create mode 100644 rtod.m create mode 100644 string_learning.m create mode 100644 stringfind.m create mode 100644 structdata.m create mode 100644 sum_n.m create mode 100644 tran.m create mode 100644 tyrcaatch.m diff --git a/A01.m b/A01.m new file mode 100644 index 0000000..cc1d64e --- /dev/null +++ b/A01.m @@ -0,0 +1,10 @@ +shu=[]; +for m=100:999 + m1=fix(m/100); + m2=rem(fix(m/10),10); + m3=rem(m,10); + if m == m1^3 + m2^3 + m3^3 + shu=[shu,m]; + end +end +disp(shu) \ No newline at end of file diff --git a/A02.m b/A02.m new file mode 100644 index 0000000..c948d81 --- /dev/null +++ b/A02.m @@ -0,0 +1,6 @@ +y = 0; +n = 100; +for i=1:n + y=y+1/(i*i); +end +y \ No newline at end of file diff --git a/A03.m b/A03.m new file mode 100644 index 0000000..dd67a80 --- /dev/null +++ b/A03.m @@ -0,0 +1,14 @@ +a = 0; +b = 3 * pi; +n = 1000; +h = (b-a)/n; +x=a; +s=0; +f0=exp(-0.5*x)*sin(x+pi/6); +for i=1:n + x=x+h; + f1=exp(-0.5*x)*sin(x+pi/6); + s=s+(f0+f1)*h/2; + f0=f1; +end +s \ No newline at end of file diff --git a/c5_5_3.m b/c5_5_3.m new file mode 100644 index 0000000..bacbc29 --- /dev/null +++ b/c5_5_3.m @@ -0,0 +1,6 @@ +x=(0:pi/100:2*pi); +y1=2*exp(-0.5*x); +y2=2*exp(-0.5*x).*sin(2*pi*x); +x1=(0:12)/2; +y3=2*exp(-0.5*x1).*sin(2*pi*x1); +plot(x,y1,'k:',x,y2,'b--',x1,y3,'rp'); \ No newline at end of file diff --git a/c5_5_6.m b/c5_5_6.m new file mode 100644 index 0000000..6d9fdce --- /dev/null +++ b/c5_5_6.m @@ -0,0 +1,10 @@ +x=(0:pi/100:2*pi)'; +y1=2*exp(-0.5*x)*[1,-1]; +y2=2*exp(-0.5*x).*sin(2*pi*x); +plot(x,y1,'b:'); +axis([0,2*pi,-2,2]); +hold on; +plot(x,y2,'k'); +legend('包络线','包络线','曲线y'); +hold off; +grid on; \ No newline at end of file diff --git a/c5_5_7.m b/c5_5_7.m new file mode 100644 index 0000000..7781117 --- /dev/null +++ b/c5_5_7.m @@ -0,0 +1,4 @@ +x=linspace(0,2*pi,60); +y=sin(x); +z=cos(x); +t = sin(x) ./ (cos(x)+eps); \ No newline at end of file diff --git a/c5_5_9.m b/c5_5_9.m new file mode 100644 index 0000000..4ea3d51 --- /dev/null +++ b/c5_5_9.m @@ -0,0 +1,10 @@ +x=0:0.1:100; +y=10*x.*x; +subplot(2,2,1);plot(x,y); +title('plot(x,y)');grid on; +subplot(2,2,2);semilogx(x,y); +title('semilogx(x,y)');grid on; +subplot(2,2,3);semilogy(x,y); +title('semilogy(x,y)');grid on; +subplot(2,2,4);loglog(x,y); +title('loglog(x,y)');grid on; \ No newline at end of file diff --git a/c_5_5_5.m b/c_5_5_5.m new file mode 100644 index 0000000..2122531 --- /dev/null +++ b/c_5_5_5.m @@ -0,0 +1,22 @@ +x=linspace(0,10,100); +y=[]; +for x0=x + if x0>=8 + y=[y,1]; + elseif x0>=6 + y=[y,5-x0/2]; + elseif x0>=4 + y=[y,2]; + elseif x0>=0 + y=[y,sqrt(x0)]; + end +end +plot(x,y); +axis([0,10,0,2.5]); +title('分段函数曲线'); +xlabel('Variable X'); +ylabel('Variable Y'); +text(2,1.3,'y=x^{1/2}'); +text(4.5,1.9,'y=2'); +text(7.3,1.5,'t=5-x/2'); +text(8.5,0.9,'y=1'); \ No newline at end of file diff --git a/ctr.m b/ctr.m new file mode 100644 index 0000000..803b20e --- /dev/null +++ b/ctr.m @@ -0,0 +1,11 @@ +clear; +load ctr.mat A +X = A(:,1); +[xed,xh]=sort(X); +[m,n]=size(A); +C = []; +for i = 1 : m + B = A(xh(m-i+1),1:n); + C = [C;B]; +end +num2str([(1 : m)' C]) \ No newline at end of file diff --git a/ctr.mat b/ctr.mat new file mode 100644 index 0000000000000000000000000000000000000000..1e87b9d9a28aabbd47e9d78257a3982f97fe23ea GIT binary patch literal 324 zcmeZu4DoSvQZUssQ1EpO(M`+DN!3vZ$Vn_o%P-2cQV4Jk_w+L}(NSazS-{s?2KFYdh_ExJpjc{;Pg^T*03`dfn@8?xMLebA;x_ z1? 360 + grid -= 360; +elseif grid < 0 + grid += 360; +end \ No newline at end of file diff --git a/ifelse.m b/ifelse.m new file mode 100644 index 0000000..93ca4d9 --- /dev/null +++ b/ifelse.m @@ -0,0 +1,15 @@ +% x=input('please type a number \n'); +% if fix(x) == x +% disp(x); +% end + +a = input('a=?'); +b = input('b=?'); +c = input('c=?'); +d = b * b - 4 * a * c ; +if d > 0 + x = [(-b + sqrt(d))/(2 * a),(-b - sqrt(d))/(2 * a)]; + disp(['x1=',num2str(x(1)),'x2=',num2str(x(2))]); +else + disp('无解!!! 请重新输入'); +end \ No newline at end of file diff --git a/ifelse2.m b/ifelse2.m new file mode 100644 index 0000000..3218ab5 --- /dev/null +++ b/ifelse2.m @@ -0,0 +1,10 @@ +c = input ('请输入字母','s'); +if c >= 'A' && c <= 'Z' + disp(lower(c)); +elseif c >= 'a' && c <= 'z' + disp(upper(c)); +elseif c >='0' && c <='9' + disp(str2double(c)^2); +else + disp(c); +end \ No newline at end of file diff --git a/inv_learn.m b/inv_learn.m new file mode 100644 index 0000000..e6a01fd --- /dev/null +++ b/inv_learn.m @@ -0,0 +1,9 @@ +N = [5.2,2.4,0,-1.7;2.4,7.4,2.3,2.7;0,2.3,6.3,0;-1.7,2.7,0,4.4]; +W = -[7;8;6;-3]; +K = (inv(N)*W)'; +disp(K); +N * inv(N) +[V,D]= eig(N) +abs(N*V-V*D) +b = mean(N) +c = std(N) \ No newline at end of file diff --git a/leica2.m b/leica2.m new file mode 100644 index 0000000..85b2039 --- /dev/null +++ b/leica2.m @@ -0,0 +1,10 @@ +filename = 'leika.txt'; +fp = fopen(filename,"r"); +i = 0; +while ~feof(fp) + i = i + 1; + for j = 1 : 4 + zb(i,j)=fscanf(fp,'%f',1); + end +end +fclose(fp); \ No newline at end of file diff --git a/leica3.m b/leica3.m new file mode 100644 index 0000000..6a5c162 --- /dev/null +++ b/leica3.m @@ -0,0 +1,9 @@ +filename = 'leika.txt'; +fp = fopen(filename,"r"); +i = 0; +zb=[]; +while ~feof(fp) + line = fgetl(fp) + my = sscanf(line,'%g') +end +fclose(fp); \ No newline at end of file diff --git a/leika.m b/leika.m new file mode 100644 index 0000000..83afdb5 --- /dev/null +++ b/leika.m @@ -0,0 +1,4 @@ +filename='leika.txt'; +fp = fopen(filename,"r"); +zb = fscanf(fp,'%f'); +fclose(fp); diff --git a/leika.txt b/leika.txt new file mode 100644 index 0000000..61bbf00 --- /dev/null +++ b/leika.txt @@ -0,0 +1,6 @@ +20 50122.563 79997.730 401.113 +21 50122.794 80011.106 401.085 +22 50004.381 80007.744 399.831 +23 50119.260 79997.344 401.181 +24 50006.659 80024.175 399.504 +25 50105.337 79995.006 400.849 \ No newline at end of file diff --git a/magic5.dat b/magic5.dat new file mode 100644 index 0000000000000000000000000000000000000000..1654c4fde62e917ff1e0d491b348ca7fcdad206c GIT binary patch literal 100 ycmWN=1rC5P5CE{l87{;A|54hcdqh0e4vxMywoV=vcFvxD_AX{GOIJ5GFLD%Ffvsj5-`93qo*%FkR1fX6>}aZCnOXkq$DIT zUy|VwkYb5gSW~C)j3voUp@iwu8HY3MA^-o|GfO47JXAbwJV~+NS65F|q4LhI#9xwu Y6*JzYA5a9!uZr^dt6;{k`ncRl00!JW=>Px# literal 0 HcmV?d00001 diff --git a/newafile.m b/newafile.m new file mode 100644 index 0000000..12f613e --- /dev/null +++ b/newafile.m @@ -0,0 +1,3 @@ +fid = fopen('magic5.dat','w'); +cnt = fwrite(fid,magic(5),"int32"); +fclose(fid); \ No newline at end of file diff --git a/nikon.m b/nikon.m new file mode 100644 index 0000000..94c9901 --- /dev/null +++ b/nikon.m @@ -0,0 +1,14 @@ +filename1='nikon.txt'; +fp=fopen(filename1,'r'); +i=1;zb=[]; +while ~feof(fp) + line=fgetl(fp); + my=strfind(line,','); + zb(i).dh=line(1:my(1)-1); + zb(i).x=str2num(line(my(1)+1:my(2)-1)); + zb(i).y=str2num(line(my(2)+1:my(3)-1)); + zb(i).h=str2num(line(my(3)+1:my(4)-1)); + zb(i).dm=line(my(4)+1:end); + i=i+1; +end +fclose(fp); \ No newline at end of file diff --git a/nikon.txt b/nikon.txt new file mode 100644 index 0000000..fa7a74a --- /dev/null +++ b/nikon.txt @@ -0,0 +1,7 @@ +3,49510.3110,80362.3190,405.8240,s50 +63,49488.9080,80426.0080,408.8490,S77 +164,49461.2960,80462.3610,408.9950,S77 +165,49457.2500,80485.8770,409.4490,S81 +166,49476.6650,80395.8870,408.1090,S66 +167,49475.1380,80398.7300,408.1570,S77 +298,49465.2360,80593.9700,415.1290,S99 \ No newline at end of file diff --git a/plot04.m b/plot04.m new file mode 100644 index 0000000..843b994 --- /dev/null +++ b/plot04.m @@ -0,0 +1,2 @@ +y=peaks; +plot(y); \ No newline at end of file diff --git a/plot_learn.m b/plot_learn.m new file mode 100644 index 0000000..83ad5bf --- /dev/null +++ b/plot_learn.m @@ -0,0 +1,3 @@ +x = (1:1:20); +y = x / 3; +plot(x,y) \ No newline at end of file diff --git a/plotxy01.m b/plotxy01.m new file mode 100644 index 0000000..3c64163 --- /dev/null +++ b/plotxy01.m @@ -0,0 +1,3 @@ +x = linspace(0,2 * pi); +y = sin(x); +plot(x,y); \ No newline at end of file diff --git a/plotxy02.m b/plotxy02.m new file mode 100644 index 0000000..00be382 --- /dev/null +++ b/plotxy02.m @@ -0,0 +1,3 @@ +x=linspace(0,2*pi,100); +y=[sin(x);cos(x)]; +plot(x,y); \ No newline at end of file diff --git a/plotxy03.m b/plotxy03.m new file mode 100644 index 0000000..6ae5b5b --- /dev/null +++ b/plotxy03.m @@ -0,0 +1,2 @@ +x=linspace(0,2*pi,100); +plot(x,sin(x),'.',x,cos(x),'<', x,cos(x)+sin(x),'>'); \ No newline at end of file diff --git a/plotxy08.m b/plotxy08.m new file mode 100644 index 0000000..69da144 --- /dev/null +++ b/plotxy08.m @@ -0,0 +1,4 @@ +x = linspace(0,2*pi); +y1=sin(x); +y2=exp(-x); +plotyy(x,y1,x,y2); \ No newline at end of file diff --git a/plotxy09.m b/plotxy09.m new file mode 100644 index 0000000..791cd23 --- /dev/null +++ b/plotxy09.m @@ -0,0 +1,3 @@ +x=0:0.5:4*pi; +y=sin(x); +plot(x,y,'b->') \ No newline at end of file diff --git a/plotxy10.m b/plotxy10.m new file mode 100644 index 0000000..6b32efe --- /dev/null +++ b/plotxy10.m @@ -0,0 +1,4 @@ +x=0:0.1:4*pi; +y=sin(x); +plot(x,y); +axis([-inf,inf,0,1]); \ No newline at end of file diff --git a/price.m b/price.m new file mode 100644 index 0000000..7de9585 --- /dev/null +++ b/price.m @@ -0,0 +1,15 @@ +price=input('请输入价格'); +switch fix(price/100) + case {0,1} + rate = 0; + case {2,3,4} + rate=3/100; + case num2cell(5:9) + rate=5/100; + case num2cell(10:24) + rate=8/100; + rate=10/100; + otherwise + rate=14/100; +end +price=price*(1-rate) \ No newline at end of file diff --git a/raddeg.m b/raddeg.m new file mode 100644 index 0000000..c248273 --- /dev/null +++ b/raddeg.m @@ -0,0 +1,9 @@ +clear; +rad=5.43813680292244; +rad=rem(rad,2*pi)*180/pi; +deg=fix(rad); +xsbf=(rad-deg)*60; +degf=fix(xsbf); +degm=(xsbf-degf)*60; +jdeg=deg+degf/100.0+degm/10000.0; +disp(jdeg); \ No newline at end of file diff --git a/rtod.m b/rtod.m new file mode 100644 index 0000000..1eaff8f --- /dev/null +++ b/rtod.m @@ -0,0 +1,7 @@ +function jdeg=rtod(rad) +rad=rad*180/pi; +deg=fix(rad); +xsbf=(rad-deg)*60; +degf=fix(xsbf); +degm=(xsbf-degf)*60; +jdeg=deg+degf/100.0+degm/10000.0; \ No newline at end of file diff --git a/string_learning.m b/string_learning.m new file mode 100644 index 0000000..8c2c7ba --- /dev/null +++ b/string_learning.m @@ -0,0 +1,18 @@ +% str1 = 'I like matlab,'; +% str2 = 'JavaScript, and Perl!'; +% str3 = [str1 str2]; +% disp(str3) + +% ansi编码 +% str1 = 'abcdefgh'; +% str2 = upper(str1); +% str3 = lower(str2); +% double(str1) +% double(str2) + +% 比较 +str1 = 'today'; +str2 = 'tomorrow'; +str3 = 'today'; +out1 = strcmp(str1,str2) +out2 = strcmp(str1,str3) \ No newline at end of file diff --git a/stringfind.m b/stringfind.m new file mode 100644 index 0000000..b6de58d --- /dev/null +++ b/stringfind.m @@ -0,0 +1,2 @@ +b = '23,T02,78354.344,89342.333,437.557,0203'; +w = findstr(',',b) \ No newline at end of file diff --git a/structdata.m b/structdata.m new file mode 100644 index 0000000..3d0e584 --- /dev/null +++ b/structdata.m @@ -0,0 +1,11 @@ +total.name='23'; +total.x=78354.344; +total.y=89342.333; +total.h=437.557; +total.code='0203'; + +total(2) = struct('name','23','xyh',[78354.344,89342.233,437.557],'code','0203') +total(1).x=76434.455; +disp(total) +total(1)=[] +rmfield(total(1),'code') \ No newline at end of file diff --git a/sum_n.m b/sum_n.m new file mode 100644 index 0000000..5d282fe --- /dev/null +++ b/sum_n.m @@ -0,0 +1,9 @@ +n=1;s=1; +while s <= 10000 + n = n + 1;s = s + n; +end +if s - 10000 > abs(s - n - 10000) + [n-1 s-n] +else + [n s] +end \ No newline at end of file diff --git a/tran.m b/tran.m new file mode 100644 index 0000000..0fc4db2 --- /dev/null +++ b/tran.m @@ -0,0 +1,3 @@ +function [rho,theta]=tran(x,y) +rho = sqrt(x^2 + y^2); +theta=atan(y/x); \ No newline at end of file diff --git a/tyrcaatch.m b/tyrcaatch.m new file mode 100644 index 0000000..85e9c54 --- /dev/null +++ b/tyrcaatch.m @@ -0,0 +1,7 @@ +A = input('矩阵A'); +B = input('矩阵B'); +try + C = A * B +catch + lasterr +end \ No newline at end of file