Thread Subject: How to hide _some_ commands in published m-files?

Subject: How to hide _some_ commands in published m-files?

From: Andres

Date: 9 Oct, 2008 14:22:01

Message: 1 of 3

Hi,

is there any kind of switch to hide a specific command in a published m-file? E.g. with a source file like this...

?
%% Demo file

% assign constants
a = 3;
b = 5;

% algorithm
c = a./b;

disp(['Result for c: ' num2str(100*c) '%']) % hide this
?

I want all commands to show up in the published file except for the disp(... command, but I want its output
?
Result for c: 60%
?
to appear.
Thanks for your thoughts,
Andres

Subject: How to hide _some_ commands in published m-files?

From: Steven Lord

Date: 9 Oct, 2008 15:49:01

Message: 2 of 3


"Andres " <rantore@werb.deNoRs> wrote in message
news:gcl429$pco$1@fred.mathworks.com...
> Hi,
>
> is there any kind of switch to hide a specific command in a published
> m-file? E.g. with a source file like this...
>
> ?
> %% Demo file
>
> % assign constants
> a = 3;
> b = 5;
>
> % algorithm
> c = a./b;
>
> disp(['Result for c: ' num2str(100*c) '%']) % hide this
> ?
>
> I want all commands to show up in the published file except for the
> disp(... command, but I want its output
> ?
> Result for c: 60%
> ?
> to appear.

There may be a more sophisticated way to do this, but one easy way is to
write a short script file and call that script file instead of DISP:

displayResult;

where displayResult.m is:

% begin displayResult.m
disp(['Result for c: ' num2str(100*c) '%'])
% end displayResult.m

--
Steve Lord
slord@mathworks.com

Subject: How to hide _some_ commands in published m-files?

From: Andres

Date: 10 Oct, 2008 08:49:17

Message: 3 of 3

"Steven Lord" <slord@mathworks.com> wrote in message <gcl95d$1bd$1@fred.mathworks.com>...
>
> "Andres " <rantore@werb.deNoRs> wrote in message
> news:gcl429$pco$1@fred.mathworks.com...
> > Hi,
> >
> > is there any kind of switch to hide a specific command in a published
> > m-file? [..]
> There may be a more sophisticated way to do this, but one easy way is to
> write a short script file and call that script file instead of DISP:
> [..]

Thanks for your idea, Steve. I'd then have to write a script or function for any kind of code I want to hide, but it would definitely make the published file look a bit better.

Maybe the only 'more sophisticated' method would be to post-process the html-file, i.e.

- add a keyword comment to each line of code to hide, like '% *hide*'
- write a function publishAndHide.m that publishes the m-file, looks for the keyword in the source part of the published file (after '##### SOURCE BEGIN #####'), and finally removes the corresponding lines in the html-part ...

Humph, i'll think about if it's worth the effort.
Does anybody know if the part of html-code containing one line of matlab-code could possibly span over more than a single line (wrapping,...?)? If not, finding the html-code to delete should be quite easy by directly searching the html lines (but there might be other pitfalls).
Any further thoughts about this are appreciated.

(Btw, just now I found a similar thread
http://www.mathworks.com/matlabcentral/newsreader/view_thread/174366#449320 )

Regards
Andres

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
publish Andres 9 Oct, 2008 10:25:04
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com