Plotting a multivariate polynomial with sdpvar variables

조회 수: 4 (최근 30일)
DB
DB 2022년 3월 29일
편집: Torsten 2022년 3월 30일
Suppose I have a polynomial , with degree 6. I want to plot the function where each variable in x runs from to 3.
I saw that using the meshgrid function combined with mesh should be used here. However, when applying:
[x1,x2] = meshgrid(-3:1:3, -3:1:3);
f = replace(f,[x(1) x(2)],[x1 x2])
It is said that "both arguments must have the same size". Here, [x1,x2] returns two 7x7 matrices, and the second line replaces symbolic variables [x(1) x(2)] of x = sdpvar(2,1) with the defined [x1 x2]. Some of these are from the YALMIP toolbox, but I think the core problem remains the same:
How can I set each variable from -3 to 3 and plot the polynomial function?

답변 (1개)

Torsten
Torsten 2022년 3월 29일
편집: Torsten 2022년 3월 29일
Or make f a function handle:
f = matlabFunction(f);
z = f(x1,x2);
surf(x1,x2,z)
"replace" is for strings. This doesn't suffice in the case of symbolic variables.
  댓글 수: 5
DB
DB 2022년 3월 30일
Something like this should do it, but I do not understand the steps:
https://groups.google.com/g/yalmip/c/PXQpXEjhqcA
Torsten
Torsten 2022년 3월 30일
편집: Torsten 2022년 3월 30일
I don't work with YALMIP, so I can't give you more than this link.

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

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by