Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: modify surf default behavior
Date: Thu, 4 Jun 2009 10:37:29 -0400
Organization: The MathWorks, Inc.
Lines: 54
Message-ID: <h08m6k$sd7$1@fred.mathworks.com>
References: <h06cdq$b1h$1@fred.mathworks.com> <h08968$qu$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1244126228 29095 144.212.105.187 (4 Jun 2009 14:37:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 4 Jun 2009 14:37:08 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:544821



"Aurelien Queffurust" <tug83@yahoo.fr> wrote in message 
news:h08968$qu$1@fred.mathworks.com...
> "Alan B" <monguin61@yahoo.com> wrote in message 
> <h06cdq$b1h$1@fred.mathworks.com>...
>> I would like axis('vis3d') to be run automatically when surf is called, 
>> is this possible? I can think of two things to try:
>> 1. create a new wrapper m-file, also called surf.m, that simply passes 
>> the arguments around, and calls axis('vis3d') when done. I don't know how 
>> to do this because surf is not a built-in command, so builtin() doesn't 
>> work - how can I run a specific shadowed m-file, instead of whichever 
>> MATLAB chooses as the default?
>> 2. set some default axes properties. I don't know how to do this because 
>> I was unable to understand what axis('vis3d') actually does, in terms of 
>> axes aspect ratio properties. Also, is it possible to specify different 
>> default properties for 2D vs 3D plots?
>>
>> Any help is appreciated.
>
>
> 1. Concerning shadowing a builtin
>
> You can create your own surf.m function. Then by using addpath or 
> pathtool, make the path of your own function to be the top of the path.
> The command:
>>>which -all surf
> will show you that your own surf.m is shadowing the path 
> $matlabroot\toolbox\matlab\graph3d\surf.msurf

Note that this will force ALL functions that call SURF to use your modified 
SURF.  For the specified change you want to make, that's _probably_ okay 
(assuming none of the other functions that call SURF expect the axis to be 
configured a certain way and error if it isn't) but be careful if you shadow 
other functions like this.  For instance, if you were to shadow QUIT and 
EXIT and make them not call the builtins, you're going to have an 
interesting time trying to shut down MATLAB.

Instead of doing this, I'd write my own wrapper and use it instead of SURF. 
Call it something like surfWith3dAxis:


function h = surfWith3dAxis(varargin)
h = surf(varargin{:});
axis('vis3d');


This way, those functions that expect SURF to behave a certain way will 
still work, but you've got a very simple way to get the behavior you want.

-- 
Steve Lord
slord@mathworks.com