How can specify interval of variables in fsurf?

조회 수: 15 (최근 30일)
Rahul Bhadani
Rahul Bhadani 2021년 4월 7일
답변: Mathieu NOE 2021년 4월 7일
I am following the documentation for fsurf:
There, I see an example:
f1 = @(x,y) erf(x)+cos(y);
fsurf(f1,[-5 0 -5 5])
However, I do not know what is the granularity of x and y. Let's say I am interested in x for -5 < x < 0 but interval should be 0.1, i.e. in MATLAB language it should be x= -5:0.1:0. Similarly, let say Y has -5:0.2:5
How should I accomplish that?
  댓글 수: 3
Rahul Bhadani
Rahul Bhadani 2021년 4월 7일
편집: Rahul Bhadani 2021년 4월 7일
Thank you. This is what I was looking for. You can post it as an answer so that I can accept it.
However, there may still be a room for improvement, since meshdensity may not separatelyc control granularity in two directions.
Mathieu NOE
Mathieu NOE 2021년 4월 7일
hello
will do ,
maybe in the future TMW will let you choose a different mesh density for each direction...

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

채택된 답변

Mathieu NOE
Mathieu NOE 2021년 4월 7일
hi
see 'MeshDensity' — Number of evaluation points per direction
Control Resolution of Surface Plot
Control the resolution of a surface plot using the 'MeshDensity' option. Increasing 'MeshDensity' can make smoother, more accurate plots while decreasing it can increase plotting speed.
Create two plots in a tiled chart layout. In the first plot, display the parametric surface x=sin(s), y=cos(s), z=(t/10)sin(1/s). The surface has a large gap. Fix this issue by increasing the 'MeshDensity' to 40 in the second plot. fsurf fills the gap, showing that by increasing 'MeshDensity' you increased the resolution.
tiledlayout(2,1)
nexttile
fsurf(@(s,t) sin(s), @(s,t) cos(s), @(s,t) t/10.*sin(1./s))
view(-172,25)
title('Default MeshDensity = 35')
nexttile
fsurf(@(s,t) sin(s), @(s,t) cos(s), @(s,t) t/10.*sin(1./s),'MeshDensity',40)
view(-172,25)
title('Increased MeshDensity = 40')

추가 답변 (1개)

KSSV
KSSV 2021년 4월 7일
f1 = @(x,y) erf(x)+cos(y);
x = -5:0.1:0 ;
y = -5:0.2:5 ;
[X,Y] = meshgrid(x,y) ;
Z = f1(X,Y) ;
surf(X,Y,Z)
  댓글 수: 3
KSSV
KSSV 2021년 4월 7일
I know that...but how it is going to matter surf or fsurf?
Rahul Bhadani
Rahul Bhadani 2021년 4월 7일
Because my question was specifically about using fsurf and not in general about how to make a 3D plot.

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

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by