DAY13 Matlab矩阵操作随手练习

A=[1 2 3;4 5 6];
B=[1 3 5;7 9 5];
C=A';
D=B*B';
E=[1 1 2 2 3 3 4 4 4 5];
F=unique(E);
E(2)=[];
repmat(E,4,4);
I=eye(10,10);
K=rand(10);


im1=(imread('IMG_4114.jpg'));
imshow(I);

im11=im1(:,:,1);
im12=im1(:,:,2);
im13=im1(:,:,3);

figure,imshow(im11);
figure,imshow(im12);
figure,imshow(im13);

subplot(1,3,1) 

K1=rand(0,10);
K2=0+(10-0)*rand(10,1);

date=[3 9 45 6;7 16 -1 6];
for n=date
x=n(1)-n(2);
end

num=0;EPS=1;
while(1+EPS)>1
EPS=EPS/2;
num=num+1;
end

EPS=1;
for num=1:1000;
EPS=EPS/2;
if(1+EPS)<=1
EPS=EPS*2;
break;
end
end;

a=[1 2 3;4 5 6;7 8 0];
p=poly(a);
p1=1 -6 -72 -27;
p2=poly2str(p1,'x');
r=roots(p);

x=1:2:20;
plot(x);

x=peaks;plot(x)
x=1:length(peaks);
y=peaks;
plot(x,y)

t=0:pi/100:2*pi;
y=sin(t);y1=sin(t+0.25);y2=sin(t+0.5);
plot(t,y) %—— 自动出现第一个窗口
figure(2)
plot(t,y1) % —— 在第二窗口绘图
figure(3)
plot(t,y2)

plot(t,y,'r-',t,y1,'g:',t,y2,'b*')

t=0:0.1:10;
y1=sin(t);y2=cos(t);
plot(t,y1,'r',t,y2,'b--');
x=[1.7*pi;1.6*pi];
y=[-0.3;0.8];
s=['sin(t)';'cos(t)'];
text(x,y,s);
title('正弦和余弦曲线');
legend('正弦','余弦');
%xlable('时间t'),ylable('正弦 余弦');
grid off
axis square

fplot('[sin(x),tan(x),cos(x)]',2*pi*[-1 1 -1 1])fplot('humps',[0 1],'rp')

J=imread('E:【0】摄影专用IMG_4114.jpg');
figure(1), imshow(J);
figure(2), imshow(J);
size(J);
[M,N]=size(J);

sum=0;
for i=1:5
pdr=1;
for k=1:i
pdr=pdr*k;
end
sum=sum+pdr;
end

x=1:5;
y=mean(x);

a=magic(3);
b=ones(3);
c=[a b];
d=[a:b];

 

 

  

原文地址:https://www.cnblogs.com/Qsir/p/5644868.html