Thread Subject: partial publishing of m-files

Subject: partial publishing of m-files

From: Gabriel Peyr?

Date: 14 Aug, 2008 22:23:02

Message: 1 of 5

Dear all,

Is is possible to exlude some a part of a matlab code from
being written in the html file ?

I want part of the code to be evaluated, but not output to
the html file (for instance to leave some blank in the code,
so that student fill the missing part by themselves).

Thanks a lot,

Gabriel

Subject: partial publishing of m-files

From: bogfrog

Date: 15 Aug, 2008 01:38:08

Message: 2 of 5

Why not just remove the code you want to be missing, save it as a different file name, and then publish that?

Subject: partial publishing of m-files

From: Gabriel Peyr?

Date: 15 Aug, 2008 09:21:02

Message: 3 of 5

> Why not just remove the code you want to be missing,
> save it as a different file name, and then publish that?

Some of the removed part might be critical (the remaining
part of the code will not be valid anymore).

Thanks for your reply,

Gabriel

Subject: partial publishing of m-files

From: Steven Lord

Date: 15 Aug, 2008 14:30:35

Message: 4 of 5


"Gabriel Peyr?" <gabriel.removethis.peyre@ceremade.removethat.dauphine.fr>
wrote in message news:g83hpt$95b$1@fred.mathworks.com...
>> Why not just remove the code you want to be missing,
>> save it as a different file name, and then publish that?
>
> Some of the removed part might be critical (the remaining
> part of the code will not be valid anymore).

Keep in mind that script files execute in the workspace of their caller, so
if you're worried that the code that you're removing depends on variables in
that workspace, you can put the removed code in a script. As an example,
try saving these two files and publishing file1.m:

--- Begin file1.m ---
%% Setup
% This is an example
a = 1;
b = 2;

%% Your assignment
% Your assignment, should you choose to accept it,
% is to recreate the figure below using an M-file.
% Assume that a and b are defined as above.
exerciseSolution;

--- End file1.m ---

--- Begin exerciseSolution.m ---
x = -10:0.1:10;
y = a*x+b;
plot(x, y)
--- End exerciseSolution.m ---

One benefit from this is, if you're using this to create homework for a
course (which I believe was the use case you mentioned in your original
message) you can simply distribute exerciseSolution after the assignment has
been submitted to demonstrate the answer.

If the piece of code you want to remove is _part_ of an expression, well
there's no way that I know of to pull just part of an expression into a
script or to hide it from being published. In that case, I think if you
want to hide the part you'll need to break off the whole expression into a
separate script or function file.

--
Steve Lord
slord@mathworks.com

Subject: partial publishing of m-files

From: Gabriel Peyre

Date: 16 Aug, 2008 02:18:02

Message: 5 of 5

> One benefit from this is, if you're using this to create
homework for a
> course (which I believe was the use case you mentioned in
your original
> message) you can simply distribute exerciseSolution after
the assignment has
> been submitted to demonstrate the answer.

This is perfect !

Thanks a lot,

Gabriel

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 Matthew Simoneau 20 Aug, 2008 23:06:56
publishing Gabriel Peyre 14 Aug, 2008 18:25:04
rssFeed for this Thread

Contact us at files@mathworks.com