Check to see if this is correct.

1 回表示 (過去 30 日間)
Joshua
Joshua 2014 年 2 月 28 日
回答済み: Anuj 2014 年 2 月 28 日
I'm getting strange numbers, everything is 27.0000 or something fla tlike that. Here is what I am supposed to do: http://i.imgur.com/BsCjNvR.png
Here is my code:
function result = nicholson5(a,x)
k = 1;
result = 1;
error = 1;
if ~(a == 0 && x == 0)
while (error >= 0.000001)
result = (((x * log(a))^k) / factorial(k))+ result;
error = (((x * log(a))^k+1) / factorial(k+1));
k = k + 1;
end
else
result = 0;
end
end

回答 (1 件)

Anuj
Anuj 2014 年 2 月 28 日
There's no problem with the code, its fine. Just include
a=input('a= ') ;
x=input('x= ');
after function and on the top,
clear nicholson5;
Regards

カテゴリ

Help Center および File ExchangeElementary Math についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by