Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

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

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.

Contact us