How to solve this problem: Not enough input arguments. Nonlinear equations, Vegstein
조회 수: 1 (최근 30일)
이전 댓글 표시
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);
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!