commit 49047b316d687fe1ab3d84d40e51bb874696a34e Author: bisnsh Date: Fri Oct 10 17:29:33 2025 +0800 Initial commit 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 0000000..1e87b9d Binary files /dev/null and b/ctr.mat differ diff --git a/deg2rad.m b/deg2rad.m new file mode 100644 index 0000000..d6ed69a --- /dev/null +++ b/deg2rad.m @@ -0,0 +1,9 @@ + + + +function jrad=deg2rad(deg) +degd=fix(deg); +degf=(deg-degd)*100; +degm=fix(degf); +degs=(degf-degm)/36.0; +jrad=(degd+degm/60.00+degs)* pi / 180.0; diff --git a/det_learn.m b/det_learn.m new file mode 100644 index 0000000..5f2349b --- /dev/null +++ b/det_learn.m @@ -0,0 +1,3 @@ +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]; +D = det(N) +DJ = diag(N)' \ No newline at end of file diff --git a/diag_learn.m b/diag_learn.m new file mode 100644 index 0000000..f116e9b --- /dev/null +++ b/diag_learn.m @@ -0,0 +1,3 @@ +D = diag([1,2,3;4,5,6;7,8,9]); +disp(D) +diag([1,1,1,2,2,2]) \ No newline at end of file diff --git a/example1.m b/example1.m new file mode 100644 index 0000000..35357aa --- /dev/null +++ b/example1.m @@ -0,0 +1,2 @@ +a=[1,2,3;4,5,6;7,8,9] +a=a([2,2],:) \ No newline at end of file diff --git a/example2.m b/example2.m new file mode 100644 index 0000000..0fcfb97 --- /dev/null +++ b/example2.m @@ -0,0 +1,4 @@ +clear +a=eye(3,3) +b=[7 8 9] +a(3,:)=b([3 1 2]) \ No newline at end of file diff --git a/exch.m b/exch.m new file mode 100644 index 0000000..c55995a --- /dev/null +++ b/exch.m @@ -0,0 +1,6 @@ +clear; +a=1:10; +b=[11,12,13,14;15,16,17,18]; +c=a;a=b;b=c; +a +b \ No newline at end of file diff --git a/foo.m b/foo.m new file mode 100644 index 0000000..5081f10 --- /dev/null +++ b/foo.m @@ -0,0 +1,4 @@ +function foo(x,y) + if nargin ~= 2 + error('Warning number of input argument') + end \ No newline at end of file diff --git a/gridbearing.m b/gridbearing.m new file mode 100644 index 0000000..2dd99b9 --- /dev/null +++ b/gridbearing.m @@ -0,0 +1,7 @@ +function grid=gridbearing(a,b) +grid = a + b ; +if grid > 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 0000000..1654c4f Binary files /dev/null and b/magic5.dat differ diff --git a/matlab.mat b/matlab.mat new file mode 100644 index 0000000..468ff38 Binary files /dev/null and b/matlab.mat differ 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