Please change this code from inline to function.

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Star Strider
Star Strider il 11 Apr 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.

Più risposte (0)

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!

Translated by