前几天都没发博客,主要是系统的学习了AJAX,然后快速入门了VUE,对Spring 和SpringMVC都有了一定的学习。
然后今天学习了一下基础的matlab语法,基本代码如下所示:
a = [1 2 3;4 5 2;3 2 7 ]; b = [1 1 1;2 2 2]; % 这里c就是b的转置矩阵 c= b' %d就是b的从列拉长的一串 d = b(:) % e是a的逆矩阵 e = inv(a) a * e zero1 = zeros(3,4,3) %rand(3,4)的作用就是生成0-1之间的随机数,3行4列的 zero1(:,:,1) = rand(3,4) %生成标准正态分布的伪随机数 zero1(:,:,2) = randn(3,4) %主要语法:randi (iMax)在开区间(0,iMax)生成均匀分布的伪随机整数 %randi(iMax,m, n)在开区间(0,iMax)生成mXn型随机矩阵 :冒号的作用是取全部 zero1(:,:,3) = randi([1,10],3,4) %元胞数组 A = cell(1,6) A{2} = eye(3) C = magic(5) B = cell(2,4) books = struct('name',{{'machine learning','Data Mining'}},'price',[30,40]) books.name books.name(1) books.name{1} %矩阵的定义和构造 AA = [1 2 3 5 8 5 4 6] BB = 1:1:9 CC = repmat(BB,3,1) DD = ones(1,2) A = [1 2 3;4 5 6;7 8 9] B = [2 3 4;3 4 5;5 6 7] % 所有的.然后再加一个运算符都是对应位置做运算,而单纯的* / 是利用了矩阵的×运算 /就等于×一个逆 A+B A-B A*B' A.*B A/B A./B Magic1 = magic(5) Magic1(1,1) [m,n] = find(Magic1>20) sum = 0 for n = 1:2:5 sum = sum + n^2; end sum %用for循环求一到五的i的阶乘的值 sum1 = 0 for i = 1:5 sum11 = 1 for j = 1:i sum11= sum11 * j end sum1 = sum1 + sum11 end sum1 % 九九乘法表 for i = 1:9 for j =1:i c = i*j end end %while使用计算1到10 number = 1 all = 0 while number<101 all = all + number; number = number + 1; end all %switch case 这个在每一个case的背后都自带break a = 111 switch (a) case 111 a = 114; case 111 a = 115 end a % 二维平面画图的基本操作 x = 0:0.01:2*pi; y = sin(x); figure plot(x,y) title('y = sin(x)') xlabel('x') ylabel('sin(x)') xlim([0,2*pi]) %限制默认展示的x的范围 x = 0:0.01:20; y1 = 200*exp(-0.05*x).*sin(x); y2=0.8*exp(-0.5*x).*sin(10*x); figure [AX,H1, H2] = plotyy(x, y1,x, y2,'plot') set(get(AX(1),'Ylabel'), 'String', 'Slow Decay') set(get(AX(2), 'Ylabel'), 'String', 'Fast Decay') xlabel('Time (\musec)') title('Multiple Decay Rates') set(H1,'LineStyle','--') set(H2,'LineStyle',':')
标签:end,name,5.9,sum,sum1,books,iMax,日结 From: https://www.cnblogs.com/laohei114514/p/17386488.html