Please change this code from inline to function.

2 vues (au cours des 30 derniers jours)
지원 안
지원 안 le 11 Avr 2021
Commenté : Stephen23 le 12 Avr 2021
clear all
clc
format short
f1=inline('2*x.^3+y.^3+x.*y-6');
f2=inline('x.^3-y.^3+x.*y-4;');
clear i
X0=[i 1+i]; X1=[-i i-2]; X2=[i+1 1];
for k=1:21
M=[X0 1; X1 1; X2 1];
v=[f1(X0(1),X0(2)); f1(X1(1),X1(2)); f1(X2(1),X2(2))];
c1=M\v;
v=[f2(X0(1),X0(2)); f2(X1(1),X1(2)); f2(X2(1),X2(2))];
c2=M\v;
c=[c1';c2'];
X=-c(1:2,1:2)\c(:,3);
X0=X1; X1=X2; X2=X';
end
  1 commentaire
Stephen23
Stephen23 le 12 Avr 2021
The very start of the inline documentation states

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 11 Avr 2021
This is straightforward —
f1=inline('2*x.^3+y.^3+x.*y-6');
f2=inline('x.^3-y.^3+x.*y-4;');
magickally becomes —
f1 = @(x,y) 2*x.^3+y.^3+x.*y-6;
f2 = @(x,y) x.^3-y.^3+x.*y-4;
See the documentation section on Anonymous Functions for details.

Plus de réponses (0)

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!

Translated by