How to solve this problem: Not enough input arguments. Nonlinear equations, Vegstein

1 回表示 (過去 30 日間)
Ivan Kolomiets
Ivan Kolomiets 2020 年 7 月 14 日
編集済み: Govind Narayan Sahu 2020 年 7 月 14 日
function [ root, k ] = veg(f,a,b)
e = 0.00001;
x0 = a;
x1 = b;
xn = x1 - (f(x1)*(x1-x0)/(f(x1)-f(x0)));
k = 1;
while (abs(x1-xn)>e)
k = k+1;
x0 = x1;
x1 = xn;
xn = x1 - (f(x1)*(x1-x0)/(f(x1)-f(x0)));
end
root = xn;
end
[x1f1_vegstein,k] = veg(f1,1.4,1.8);
error1 = abs((abs(x1f1_vegstein)-abs(x1f1))/x1f1);
table(x1f1_vegstein,k,error1)
function f = f1(x1)
f = 2*x1.^4+8*x1.^3-18*x1.^2-1;
end
Not enough input arguments.
Error in f1 (line 2)
f = 2*x1.^4+8*x1.^3-18*x1.^2-1;
Error in lr6 (line 77)
[x1f1_vegstein,k] = veg(f1,1.4,1.8);

回答 (1 件)

Govind Narayan Sahu
Govind Narayan Sahu 2020 年 7 月 14 日
編集済み: Govind Narayan Sahu 2020 年 7 月 14 日
use @ symbol with f1 as given below:
[x1f1_vegstein,k] = veg(@f1,1.4,1.8);
After that you will get the root but also get the error since you have not created the variable x1f1. Please check.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by