Error using ==> inline.subsref at 14 Not enough inputs to inline function.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Walter Roberson
le 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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Function Creation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!