
Please change this code from inline to function.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
Réponse acceptée
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;
0 commentaires
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!