Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Wrongly computed NaN's when plotting a parametric surface with ezsurf

5 Ansichten (letzte 30 Tage)
Roberto Ferrara
Roberto Ferrara am 1 Dez. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
In the following code I use an anonymous fuction to plot a surface. The function uses if contitions and NaN's to plot over a non square domain. However, some points near the boundary, but inside the domain, that are computed correctly by the function (if called manually) are computed as NaN's by ezsurf.
What's wrong here?
Minimal code:
ezsurf(@(x,y) iff(1-x-y>=0, max([-1/2, -sqrt(x*y)-(1-x-y)]), nan), [0,1,0,1]) ;
hold on
ezplot3(@(x) x, @(x) 1-x , @(x) -sqrt(x*(1-x)),[0,1,0,1]);
tmp = @(x,y) iff(1-x-y>=0, max([-1/2, -sqrt(x*y)-(1-x-y)]));
tmp(0,1)
ans = 0
The second plot, prints the border (computed correctly), to where the surface should reach; The last two line show that the point x,y = 0,1 should be plotted according to the function.
where iff.m:
function x = iff( a, b, c )
if a
x = b;
else
x = c;
end
end
PS: yes, i could compute the data points myself and use surf, but then what's the point of having ezsurf if i cannot make it work properly.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by