How can i plot this symbolic function?

5 Ansichten (letzte 30 Tage)
Volli
Volli am 16 Jun. 2017
Kommentiert: Volli am 20 Jun. 2017
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!

Antworten (1)

Sagar Doshi
Sagar Doshi am 20 Jun. 2017
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 Kommentar
Volli
Volli am 20 Jun. 2017
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.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by