How to solve this problem: Not enough input arguments. Nonlinear equations, Vegstein
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Govind Narayan Sahu
on 14 Jul 2020
Edited: Govind Narayan Sahu
on 14 Jul 2020
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 Comments
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!