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 13:28:14 -0400
Organization: The MathWorks, Inc.
Lines: 63
Message-ID: <h0906o$hjt$1@fred.mathworks.com>
References: <h06cdq$b1h$1@fred.mathworks.com> <h08nre$m1d$1@fred.mathworks.com> <h08p62$lt7$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1244136472 18045 144.212.105.187 (4 Jun 2009 17:27:52 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 4 Jun 2009 17:27:52 +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:544862



"Alan B" <monguin61@yahoo.com> wrote in message 
news:h08p62$lt7$1@fred.mathworks.com...
>> Why not just write your own wrapper function? Call it
>> mysurf, or something like that. This way surf will work
>> as it is designed for others, or for the case in the future
>> when you don't want that. (It will happen too.)
>>
>> John
>>
>> (I'm going to write my own wrapper for surf. I'll call
>> it smurf. Of course, it will always use a pure blue
>> colormap.)
>
> Of course you're correct here, if I modify the default behavior, SOMETHING 
> will eventually break. Its more a question of curiosity. Incidentally, I 
> have never wanted to use surf without axis vis3d, as far as I can 
> remember. Do you have an example where that would be desired?

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/pcolor.html

"A pseudocolor plot is a flat surface plot viewed from above. pcolor(X,Y,C) 
is the same as viewing surf(X,Y,zeros(size(X)),C) using view([0 90])."

If you were building your own tweaked version of PCOLOR, you might want to 
call SURF as part of the process of creating the plot.

> There are a few other functions with behavior that bothers me. For 
> example, 'open nonexistentFunction' errors, and since I have 'dbstop if 
> error' enabled, every time I make a typo using 'open' at the command line, 
> I get open.m needlessly opening up in my editor.

That's why I use EDIT -- if the file you're trying to edit doesn't exist, it 
instead asks if I want to create it.

> My personal preference would be a warning or message instead of an error, 
> and I would like to continue using 'open' instead of 'myopen' simply 
> because I'm lazy. I have a hard time imagining how making that change 
> might break anything. (I also wouldn't mind being able to enable 'dbstop 
> if error' on a by-function basis)

Okay, so you make OPEN warn and complete its execution instead of erroring. 
Now functions that call OPEN inside TRY/CATCH and check the error that OPEN 
threw (if there was a problem, like a nonexistent file) may assume that 
since OPEN didn't error, it was able to successfully open the file.  A key 
point to remember is that OPEN doesn't just open M-files, it can open lots 
of different types of files, including FIG-files.  Because they assume they 
were able to successfully open the file, they continue running only to fall 
over tens or hundreds of lines later when they try to use the (non-existent) 
figure or model or file.

> If this can't be done, its not a big deal. Just thought I'd ask.

It _can_ be done; you can shadow built-in functions.  You should just be 
VERY careful when you do so, and often creating your own wrapper is a safer 
idea.  You will need to type two additional characters each time you call 
the function, but after a short while you probably won't even notice.

-- 
Steve Lord
slord@mathworks.com