How to solve this problem: Not enough input arguments. Nonlinear equations, Vegstein
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Govind Narayan Sahu
il 14 Lug 2020
Modificato: Govind Narayan Sahu
il 14 Lug 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 Commenti
Vedere anche
Categorie
Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!