24小时热门版块排行榜    

CyRhmU.jpeg
查看: 3032  |  回复: 5
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

我要飞

铁虫 (正式写手)

[求助] 求助matlab里面画出x^3-1=0的Newton迭代的吸引域的程序

求助matlab里面画出x^3-1=0的Newton迭代的吸引域的程序
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

我要飞(金币+10): 2011-10-19 19:01:17
引用回帖:
4楼: Originally posted by 我要飞 at 2011-10-17 11:54:02:
??? function AA
    |
Error: Function definitions are not permitted at the prompt or in scripts.
你给的程序不对呀,出像上面这样的错呀

我已经说了要在editor中保存为m文件运行
具体方法 在命令窗口输入edit 会弹出editor窗口,将代码复制,并保存在当前目录下,点击edito菜单中的run按钮

出现?? function AA
    |
Error: Function definitions are not permitted at the prompt or in scripts.

是你直接在命令窗口运行代码导致的
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
5楼2011-10-19 14:17:26
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 6 个回答

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

CODE:
function AA
p=f(-1/2-sqrt(3)/2*i , -1/2+sqrt(3)/2*i, 1)


function p=f(A,B,C)
%>>p=f(-1/2-sqrt(3)/2*i , -1/2+sqrt(3)/2*i, 1)
h=0.01;
for a=-1:h:1
for b=-1:h:1
x0=a+b*i;
y=newton(x0);
if abs(y-A)<1.0e-6
plot(a,b,'r.');
hold on
elseif abs(y-B)<1.0e-6
plot(a,b,'g.');
hold on
elseif abs(y-C)<1.0e-6
plot(a,b,'y.');
hold on
end
end
end

p=0;


function y=newton(z)

if (z==0)
y=0;
return;
end

for i=1:1:2000
y=z-(z^3-1)/(3*z^2);
if(abs(y-z)<1.0e-7)
break;
end
z=y;
end

复制到editor中运行
图形如下


The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
2楼2011-10-16 14:13:12
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

锐利的碎片

木虫 (正式写手)

star watcher


dbb627(金币+1): 确实重了,多谢交流 2011-10-16 23:35:26
3楼2011-10-16 19:15:48
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

我要飞

铁虫 (正式写手)

??? function AA
    |
Error: Function definitions are not permitted at the prompt or in scripts.
你给的程序不对呀,出像上面这样的错呀
4楼2011-10-17 11:54:02
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见