How can i plot this symbolic function?

조회 수: 3 (최근 30일)
Volli
Volli 2017년 6월 16일
댓글: Volli 2017년 6월 20일
Hello guys,
I have the following code, which calculates the Taylor-Polynom third degree of a user-given function around the point 0,0. (Also user given, but this is my test-case)
syms x y;
%f = input('Bitte geben Sie die zu evaluierende Funktion ein:','s');
f = 'exp(x^2+y^3)+x*y*(x+y)';
f = sym(f);
f = symfun(f, symvar(f, 2));
a = 0;
b = 0;
fx = diff(f,x);
fy = diff(f,y);
fxx = diff(fx,x);
fyy = diff(fy,y);
fxy = diff(fx,y);
fxxx = diff(fxx,x);
fxxy = diff(fxx,y);
fxyy = diff(fxy,y);
fyyy = diff(fyy,y);
fa = f(a,b);
fxa = fx(a,b);
fya = fy(a,b);
fxxa = fxx(a,b);
fyya = fyy(a,b);
fxya = fxy(a,b);
fxxxa = fxxx(a,b);
fxxya = fxxy(a,b);
fxyya = fxyy(a,b);
fyyya = fyyy(a,b);
t = @(x,y) fa + fxa .* (x-a) + fya .* (y-b) + 1/2 .* fxxa.*(x-a).^2 + 1/2 .* fxya .* (x-a).*(y-b) + fyya .* (y-b).^2 + 1/6 .* fxxxa .* (x-a).^3 + 1/2 .* fxxya .* (x-a).^2.*(y-b) + 1/2 .* fxyya .* (x-a).*(y-b).^2 + 1/6 .* fyyya .* (y-b).^3;
What I want to do is, plotting t. I tried different plotter but they all take an enormous amount of time, and then throw the error: Too many input arguments. But: all values (fa,fxa..., a,b) are assigned, so technically there are only two variables: x and y. Do I have a fundamental understanding-problem or where is my mistake?
Thank you for your help!

답변 (1개)

Sagar Doshi
Sagar Doshi 2017년 6월 20일
Use fsurf or fmesh.
I was able to plot 't' using both the functions in about less than 10 seconds. I think the time here is required for evaluating bunch of symbolic expressions and then plotting them.
Also try using ezplot if using older version of MATLAB.
  댓글 수: 1
Volli
Volli 2017년 6월 20일
Thank you for your answer.
In the meantime I was able to solve the problem. (I totally forgott to mention it here.)
I used:
Taylor = subs(t);
ezsurf(t(x,y));
It was fast and correct.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by