全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 MATLAB等数学软件专版
1405 7
2013-06-30
悬赏 100 个论坛币 已解决
遇到一道题目:"for computers, the machine epsilon (lets call it m) can also be thought of as the smallest number that when added to one gives a number greater than 1. An algorithm based on this idea can be developed as:

step 1 : set m = 1.
step 2 : if 1+m is less than or equal to 1, then go to step 5. otherwise go to step 3.
step 3: m = m/2
step 4: return to step 2.
step 5:m = 2*m

write you own M-file based on this algorithm to determine the machine epsilon. validate the results by running the built in file epsilon

我从网上找到一段:
%machine epsilonclc,clear
m = realmin;
while ((1+m) <= 1)   
m = 2*m;
end
m
eps


为什么要用clear?clc是什么?为什么没有如果》=1,则除以2的code?应该怎么写呢?谢谢赐教!

最佳答案

URSIMON 查看完整内容

等你开始使用matlab完成很多工作时就知道了,只是为了清爽用清屏,至于清除现有变量你不同的工作的代码可能用相同的变量名这是就会发生错误
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-6-30 12:03:36
hrbatanu 发表于 2013-6-30 12:44
谢谢回复,但是为什么要清屏和清除现有变量呢?是因为无限循环?
等你开始使用matlab完成很多工作时就知道了,只是为了清爽用清屏,至于清除现有变量你不同的工作的代码可能用相同的变量名这是就会发生错误
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-6-30 12:09:46
CLC 清屏命令;clear 清除现有变量;用if else
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-6-30 12:37:41
URSIMON 发表于 2013-6-30 12:09
CLC 清屏命令;clear 清除现有变量;用if else
为什么没有如果》=1,则除以2的code?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-6-30 12:42:04
复制代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-6-30 12:44:26
qlb061 发表于 2013-6-30 12:42
谢谢回复,但是为什么要清屏和清除现有变量呢?是因为无限循环?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群