Please change this code from inline to function.

1 回表示 (過去 30 日間)
지원 안
지원 안 2021 年 4 月 11 日
コメント済み: Stephen23 2021 年 4 月 12 日
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 件のコメント
Stephen23
Stephen23 2021 年 4 月 12 日
The very start of the inline documentation states

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2021 年 4 月 11 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by