Initial commit
This commit is contained in:
10
A01.m
Normal file
10
A01.m
Normal file
@@ -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)
|
||||
14
A03.m
Normal file
14
A03.m
Normal file
@@ -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
|
||||
6
c5_5_3.m
Normal file
6
c5_5_3.m
Normal file
@@ -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');
|
||||
10
c5_5_6.m
Normal file
10
c5_5_6.m
Normal file
@@ -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;
|
||||
4
c5_5_7.m
Normal file
4
c5_5_7.m
Normal file
@@ -0,0 +1,4 @@
|
||||
x=linspace(0,2*pi,60);
|
||||
y=sin(x);
|
||||
z=cos(x);
|
||||
t = sin(x) ./ (cos(x)+eps);
|
||||
10
c5_5_9.m
Normal file
10
c5_5_9.m
Normal file
@@ -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;
|
||||
22
c_5_5_5.m
Normal file
22
c_5_5_5.m
Normal file
@@ -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');
|
||||
11
ctr.m
Normal file
11
ctr.m
Normal file
@@ -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])
|
||||
9
deg2rad.m
Normal file
9
deg2rad.m
Normal file
@@ -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;
|
||||
3
det_learn.m
Normal file
3
det_learn.m
Normal file
@@ -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)'
|
||||
3
diag_learn.m
Normal file
3
diag_learn.m
Normal file
@@ -0,0 +1,3 @@
|
||||
D = diag([1,2,3;4,5,6;7,8,9]);
|
||||
disp(D)
|
||||
diag([1,1,1,2,2,2])
|
||||
2
example1.m
Normal file
2
example1.m
Normal file
@@ -0,0 +1,2 @@
|
||||
a=[1,2,3;4,5,6;7,8,9]
|
||||
a=a([2,2],:)
|
||||
4
example2.m
Normal file
4
example2.m
Normal file
@@ -0,0 +1,4 @@
|
||||
clear
|
||||
a=eye(3,3)
|
||||
b=[7 8 9]
|
||||
a(3,:)=b([3 1 2])
|
||||
6
exch.m
Normal file
6
exch.m
Normal file
@@ -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
|
||||
4
foo.m
Normal file
4
foo.m
Normal file
@@ -0,0 +1,4 @@
|
||||
function foo(x,y)
|
||||
if nargin ~= 2
|
||||
error('Warning number of input argument')
|
||||
end
|
||||
7
gridbearing.m
Normal file
7
gridbearing.m
Normal file
@@ -0,0 +1,7 @@
|
||||
function grid=gridbearing(a,b)
|
||||
grid = a + b ;
|
||||
if grid > 360
|
||||
grid -= 360;
|
||||
elseif grid < 0
|
||||
grid += 360;
|
||||
end
|
||||
15
ifelse.m
Normal file
15
ifelse.m
Normal file
@@ -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
|
||||
10
ifelse2.m
Normal file
10
ifelse2.m
Normal file
@@ -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
|
||||
9
inv_learn.m
Normal file
9
inv_learn.m
Normal file
@@ -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)
|
||||
10
leica2.m
Normal file
10
leica2.m
Normal file
@@ -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);
|
||||
9
leica3.m
Normal file
9
leica3.m
Normal file
@@ -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);
|
||||
4
leika.m
Normal file
4
leika.m
Normal file
@@ -0,0 +1,4 @@
|
||||
filename='leika.txt';
|
||||
fp = fopen(filename,"r");
|
||||
zb = fscanf(fp,'%f');
|
||||
fclose(fp);
|
||||
6
leika.txt
Normal file
6
leika.txt
Normal file
@@ -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
|
||||
BIN
magic5.dat
Normal file
BIN
magic5.dat
Normal file
Binary file not shown.
BIN
matlab.mat
Normal file
BIN
matlab.mat
Normal file
Binary file not shown.
3
newafile.m
Normal file
3
newafile.m
Normal file
@@ -0,0 +1,3 @@
|
||||
fid = fopen('magic5.dat','w');
|
||||
cnt = fwrite(fid,magic(5),"int32");
|
||||
fclose(fid);
|
||||
14
nikon.m
Normal file
14
nikon.m
Normal file
@@ -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);
|
||||
7
nikon.txt
Normal file
7
nikon.txt
Normal file
@@ -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
|
||||
3
plot_learn.m
Normal file
3
plot_learn.m
Normal file
@@ -0,0 +1,3 @@
|
||||
x = (1:1:20);
|
||||
y = x / 3;
|
||||
plot(x,y)
|
||||
3
plotxy01.m
Normal file
3
plotxy01.m
Normal file
@@ -0,0 +1,3 @@
|
||||
x = linspace(0,2 * pi);
|
||||
y = sin(x);
|
||||
plot(x,y);
|
||||
3
plotxy02.m
Normal file
3
plotxy02.m
Normal file
@@ -0,0 +1,3 @@
|
||||
x=linspace(0,2*pi,100);
|
||||
y=[sin(x);cos(x)];
|
||||
plot(x,y);
|
||||
2
plotxy03.m
Normal file
2
plotxy03.m
Normal file
@@ -0,0 +1,2 @@
|
||||
x=linspace(0,2*pi,100);
|
||||
plot(x,sin(x),'.',x,cos(x),'<', x,cos(x)+sin(x),'>');
|
||||
4
plotxy08.m
Normal file
4
plotxy08.m
Normal file
@@ -0,0 +1,4 @@
|
||||
x = linspace(0,2*pi);
|
||||
y1=sin(x);
|
||||
y2=exp(-x);
|
||||
plotyy(x,y1,x,y2);
|
||||
3
plotxy09.m
Normal file
3
plotxy09.m
Normal file
@@ -0,0 +1,3 @@
|
||||
x=0:0.5:4*pi;
|
||||
y=sin(x);
|
||||
plot(x,y,'b->')
|
||||
4
plotxy10.m
Normal file
4
plotxy10.m
Normal file
@@ -0,0 +1,4 @@
|
||||
x=0:0.1:4*pi;
|
||||
y=sin(x);
|
||||
plot(x,y);
|
||||
axis([-inf,inf,0,1]);
|
||||
15
price.m
Normal file
15
price.m
Normal file
@@ -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)
|
||||
9
raddeg.m
Normal file
9
raddeg.m
Normal file
@@ -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);
|
||||
7
rtod.m
Normal file
7
rtod.m
Normal file
@@ -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;
|
||||
18
string_learning.m
Normal file
18
string_learning.m
Normal file
@@ -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)
|
||||
2
stringfind.m
Normal file
2
stringfind.m
Normal file
@@ -0,0 +1,2 @@
|
||||
b = '23,T02,78354.344,89342.333,437.557,0203';
|
||||
w = findstr(',',b)
|
||||
11
structdata.m
Normal file
11
structdata.m
Normal file
@@ -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')
|
||||
9
sum_n.m
Normal file
9
sum_n.m
Normal file
@@ -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
|
||||
3
tran.m
Normal file
3
tran.m
Normal file
@@ -0,0 +1,3 @@
|
||||
function [rho,theta]=tran(x,y)
|
||||
rho = sqrt(x^2 + y^2);
|
||||
theta=atan(y/x);
|
||||
7
tyrcaatch.m
Normal file
7
tyrcaatch.m
Normal file
@@ -0,0 +1,7 @@
|
||||
A = input('矩阵A');
|
||||
B = input('矩阵B');
|
||||
try
|
||||
C = A * B
|
||||
catch
|
||||
lasterr
|
||||
end
|
||||
Reference in New Issue
Block a user