小弟报了一门课用matlab,虽然题目简单,但是毫无编程和matlab基础。希望大家指教
 
以上是题目,接下来是我写的code,不在学校手里没有matlab,暂时没run:
%%initial the values
a=2;
while (s > 0.0001)
    xold=x;
    x=(x+a/x)/2;
    s=abs((x-xold)/x);
    if(s<0.0001)
        break
    end
end
上面的哪些地方要改呢?
还有,如何reture both the result and error? 有个return的code?
display the result as a imaginary number? matlab不是自动用i吗?
谢谢