Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Specify Colormap For Multiple Surfaces

6 views
Skip to first unread message

Stormy Faw

unread,
Dec 2, 2009, 11:07:03 AM12/2/09
to
I am using matlab R2009a.
My problem is I would like to specify the color of multiple surface in matlab.

Here is part of my code.

% +----------------------------+ %
% |---- Model Body ----| %
% +-----------------------------+ %

[xbodyP,ybodyP,zbodyP] = ellipsoid(-0.03,0,0,0.07,0.02,0.02,100);
[xheadP,yheadP,zheadP] = ellipsoid(0.035,0,0,0.015,0.015,0.015,100);
h1 = surfl(xbodyP,ybodyP,zbodyP);
h2 = surfl(xheadP,yheadP,zheadP);

shading interp
colormap([.5 .5 .5]);
%set(h1, 'FaceColor','ColorSpec','[.2 .6 .5]')
%set(h2,'Color','Gray')

The commented out part was my attempt to specify the color for each surface.
Once I say colormap every surface takes that color. But if I comment that out and try to specify it with set( then it gives me errors or doesnt work at all.


Am I using handles incorrectly? Or is there a better way?

Thanks for the help

Stormy

unread,
Dec 7, 2009, 4:28:01 PM12/7/09
to
It's been a couple days and I was wondering if anyone could at least point me in the right direction. I have looked at the help menu and experimented with a couple other options.

Someone from the university mentioned using patches, but I have not worked with them so I am not sure if that would help or not.

someone

unread,
Dec 7, 2009, 4:55:03 PM12/7/09
to
"Stormy Faw" <thunder...@gmail.com> wrote in message <hf63b7$k51$1...@fred.mathworks.com>...

I'm not exactly sure what you are trying to do.
But if the above is your actual code, you are
simply overwriting the plot of h1 with h2.

If you want both plots to appear in the same figure
I think you need to insert a
hold on
statement between the two surfl commands.

Stormy

unread,
Dec 7, 2009, 5:45:20 PM12/7/09
to
"someone" <som...@somewhere.net> wrote in message <hfjtjn$18n$1...@fred.mathworks.com>...

There is actually a plot before all this were I added hold on. This is just one chunk of my code.

I am actually trying to model a bat in matlab. I read in some data files that contain wind tunnel position information and then I plot the trajectories of its limbs. Now I am trying to animate it so that it can be used for presentations. Right now though it looks really childish, so I am trying to change some surface colors, and fix the bat ears, etc. Which I will have questions for those parts as well, but at the moment I cannot figure out how to change the colors.

Thanks for the reply.

Luigi Giaccari

unread,
Dec 8, 2009, 7:10:20 AM12/8/09
to
"Stormy Faw" <thunder...@gmail.com> wrote in message <hf63b7$k51$1...@fred.mathworks.com>...

Find yourself the colormap values (just a pedestrian interpolation) and then plot the surfaces with Cdata

SURF(X,Y,Z,C)

http://www.advancedmcode.org/

0 new messages