Surface plots

142 views
Skip to first unread message

Daniel Carrera

unread,
Nov 18, 2009, 10:03:58 AM11/18/09
to freemat
Hello,

I just tried surface plots in FreeMat 4 and they don't seem to work.
They show the colours right, but you don't see a surface. Try for
example:

t = 0:0.01:1;
y = sin(2*pi*t);
w = y' * y;
surf(w)

FreeMat 4 just shows a rectangle with colours. Basically what you
would see if you were looking at the surface from above. I tried
rotating it, but it's always just a rectangle. You can't see what the
surface looks like.

If you try the above code in Octave or MATLAB or Scilab you see a
proper surface.

Is this a bug in FreeMat or just a problem with my configuration? If
this is a bug, are there plans to fix it? I am running FreeMat 4.0 on
Ubuntu Linux.

Cheers,
Daniel.

Timothy Cyders

unread,
Nov 18, 2009, 2:02:35 PM11/18/09
to fre...@googlegroups.com
The plot you're looking at is simply darn near flat. Try the exact same function, but with a scaling factor of 50 on the magnitude:


t = 0:0.01:1;
y = sin(2*pi*t);
w = 50*y' * y;
surf(w)

then change to an isometric view:

view(3)

and here's what you'll see:

http://oak.cats.ohiou.edu/~tc285202/surfex.png

Also note that using surf with only one argument (w) will not give you scale on x and y axes, just an element count.

TJ

http://oak.cats.ohiou.edu/~tc285202/surfex.png

--

You received this message because you are subscribed to the Google Groups "freemat" group.
To post to this group, send email to fre...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/freemat?hl=.



Timothy Cyders

unread,
Nov 18, 2009, 2:11:21 PM11/18/09
to fre...@googlegroups.com
Sorry, for emphasis:

Also note that using surf with only one argument (w) will not give you scale on x and y axes, just an element count. Because you're not providing the surf command with the domain for which you're passing w, it will just plot it over a number of elements, which can cause unexpected behavior in your plot (it's plotting magnitude of w vs. element number, instead of the shape it should be describing)

TJ

tapcam

unread,
Jan 11, 2010, 4:12:17 AM1/11/10
to freemat
Here's another way to handle yours, and I've included an example that
uses meshgrid.

t = 0:0.01:1;
y = sin(2*pi*t);
w = y' * y;
surf(w)
axis square
view(165,20);

% % Paraboloid
% [x,y] = meshgrid([-2:.1:2]);
% z = 5 - x.^2 - y.^2;
%
% sz=surf(x,y,z);
% set(sz,'facealpha',.3);
%
% axis square
% view(150,30);

Reply all
Reply to author
Forward
0 new messages