When you are old 当你老了 --- William Butler Yeats ——威廉·巴特勒·叶芝 When you are old and grey and full of sleep, 当你老了,头发花白,睡意沉沉, And nodding by the fire,take down this book, 倦坐在炉边,取下这本书来, And slowly read,and dream of the soft look 慢慢读着,追梦当年的眼神 Your eyes had once,and of their shadows deep; 你那柔美的神采与深幽的晕影。 How many loved your moments of glad grace, 多少人爱过你昙花一现的身影, And loved your beauty with love false or true, 爱过你的美貌,以虚伪或真情, But one man loved the pilgrim Soul in you 惟独一人曾爱你那朝圣者的心, And loved the sorrows of your changing face; 爱你哀戚的脸上岁月的留痕。 And bending down beside the glowing bars, 在炉罩边低眉弯腰, Murmur,a little sadly,how Love fled 忧戚沉思,喃喃而语, And paced upon the mountains overhead 爱情是怎样逝去,又怎样步上群山, And hid his face amid a crowd of stars. 怎样在繁星之间藏住了脸。
回首我这一生只能用四个字形容——不堪回首
好了,我要接着学习了
1.变量的命名
不能以数字和下划线开头
用字母开头
名称区分大小写
2.预定义变量名
pi(圆周率)
ans (默认计算结果的变量名)
eps(浮点相对精度)
详细介绍eps
1.默认eps=eps(1)
2.任何数的eps是不一样的,越靠近0越小,精度越大,eps(0) <eps(1)< eps(2)
3. Matlab会对eps(N)四舍五入,
1+ eps(1)*0.6=1+ eps(1)*0.7=1+ eps(1)*0.9
直接五入到1+ eps(1)*1,
1+ eps(1)*0.1=1+ eps(1)*0.2=1+ eps(1)*0.5
直接四舍到1,以刚好0.5倍为界
4. 比较2+eps(1)和2+0.6*eps(2),前者eps(1)的数量级别在0.5*eps(2)范围内,直接四舍,后者直接五入至2+eps(2),后者大于前者 5. 0.7*eps(0)五入至eps(0),0.5*eps(0)直接舍掉等于0
更为详细的介绍可以查看帮助文档
eps帮助文档
3.虚数的表示
c = 1+2*i
或者
c = 1+2*j
4.常见的数据形式
无穷大数 inf或Inf
表示非数的变量 NaN,nan
5.冒号表达式
在Matlab中输入如下代码查看结果
a = 1:10
输出结果为1,2,3,4,5,6,7,8,9,10
c = 1:0.1:10
这个表示以0.1长度为间隔分割1至10
栗子——绘制正弦图像
clear
clc
x = -2*pi:0.1:2*pi;
y = sin(x);
plot(x,y)
输出如下图
-2pi到2pi的正弦函数图像
当输入的X为矩阵时,图像是以矩阵的列进行绘制
X = [2 5 9;7 8 1;9 6 3;];
plot(X)
输出如下
三条折线
当输入两个矩阵
A = [1 2 6;3 10 9;];
B = [5 7 2;12 9 3;];
plot(A,B)
A作为横坐标,B作为纵坐标
列数决定有几条线
扩展:当x是一个复数时,则横坐标是实部,纵坐标是虚部