Error using ==> inline.subsref at 14 Not enough inputs to inline function.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
hi guys
Please if anyone can help me with my code. i face an error that says
**Error using ==> inline.subsref at 14
Not enough inputs to inline function.
x1=-4; x2=5;
F=inline('4*(sqrt(x1^2 + (10-x2)^2 )-10)^2 + 0.5*(sqrt(x1^2 + (10+x2)^2 )-10)^2 -5*(x1+x2)','x1','x2');
for j=1:200
s1=-dF1;
s2=-dF2;% dF1,dF2 can be found
x3=x1+s1*h;
x4=x2+s2*h;
%the problem is i want to use inline function as function of (h).
g=4*(sqrt(x1^3 + (10-x4)^2 )-10)^2 + 0.5*(sqrt(x3^2 + (10+x4)^2 )-10)^2 -5*(x3+x4).
f=inline('g','h');
% later in my loop i will use f(a) where a is known but i always got
*** Error using ==> inline.subsref at 14
Not enough inputs to inline function.
What I need is f as function in h so i can work with.
0 Commenti
Risposta accettata
Walter Roberson
il 18 Mar 2012
Anonymous functions are easier.
F = @(x1, x2) 4*(sqrt(x1^2 + (10-x2)^2 )-10)^2 + 0.5*(sqrt(x1^2 + (10+x2)^2 )-10)^2 -5*(x1+x2); %you do not appear to use F!
g = @(x1, x2, h) 4*(sqrt(x1^3 + (10-(x2+s2*h))^2 )-10)^2 + 0.5*(sqrt((x1+s1*h)^2 + (10+(x2+s2*h))^2 )-10)^2 -5*((x1+s1*h)+(x2+s2*h));
x1 = -4; %are these really constants??
x2 = 5; %are these really constants??
for j = 1 : 200
s1 = -dF1; %is this differential? You cannot differentiate an inline function or an anonymous function
s2 = -dF2; %differentiating what?
f = @(h) g(x1, x2, h);
end
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Function Creation 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!