MATLAB 如何改变默认的双精度为单精度,并使用单精度计算?
来源:百度知道 编辑:UC知道 时间:2024/07/07 12:39:17
第二个问题是,我就算手改,比如我有个矩阵是ju,我写命令为ju=single(ju).然后我要算本征值,利用函数eig时,就出错了。[v,d]=eig(ju).这时就会说Function 'eig' is not defined for values of class 'single'.
我该怎么办啦~~呜呜~~难道我还真要去换个2G的内存条啊,我不想啊,为了个程序我就去换,哎~~拜托谁知道帮帮忙咧。
在file\preferences\array editor里改,只是改变了输出的格式,内存中还是以double形式存储的。matlab默认的是double型的,但是可以改变的。>> a=rand(4);
>> b=single(a);
>> [v d]=eig(b)
v =
-0.4883 -0.2208 + 0.2328i -0.2208 - 0.2328i -0.4513
-0.4126 0.6612 0.6612 0.2778
-0.6205 -0.1999 + 0.1291i -0.1999 - 0.1291i 0.6267
-0.4542 -0.2364 - 0.5894i -0.2364 + 0.5894i -0.5713
d =
2.4478 0 0 0
0 -0.5604 + 0.3177i 0 0
0 0 -0.5604 - 0.3177i 0
0 0 0 -0.0946
>> whos
Name Size Bytes Class Attributes
a 4x4 1