is there a way to print the Matlab .m source code file with all subroutines?

  • Follow


Hi all,

Suppose you have written a program A.m, and you want to print it out.

Inside A.m you used functions that you've previousy written, say B.m, C.m, 
D.m.

And inside each of these subroutines you have other subroutines called E.m, 
F.m, G.m, etc...

And there are many of these programs.

You'd like to print them all out.

Is there a way this can be done automatically and in a batch mode?

Currently for hundreds of such programs, I have to open each program one by 
one and then click to print each one by one... very time consuming...

Thanks!


0
Reply housing2006 (283) 4/21/2007 9:20:10 PM

> Currently for hundreds of such programs, I have to open each program one by
> one and then click to print each one by one... very time consuming...

Remember, these are simple text files.  You don't have to open them
using the matlab editor.   Use any editors you like.

If you're in linux, you can simply concatenate them together using the
'cat' command.  If you're not in linux, I suggest learning the Perl
language (even if you are in linux, I suggest this).    Perl can help
you deal with multiple text files in intelligent ways.  It's not easy
to learn though, but the initial time invested is so much worth it in
the long run.   I've probably saved hundreds of hours alone by using
perl for various tasks such as what you describe.

In general a logical approach would be to order the filenames in order
of appearance within the code.
If A.m calls A1.m and A2.m, and A1.m  calls A1a.m and A1b.m, you'd
have

A.m
 A1.m
  A1a.m
  A1b.m
 A2.m
B.m
....
then concatenate these together, convert to postscript or pdf (linux:
man enscript, windows: MS Word/Open office Writer), then print.

0
Reply jbenjam (67) 4/22/2007 9:36:42 AM


"Ben" <jbenjam@gmail.com> wrote in message 
news:1177234602.385073.230950@n59g2000hsh.googlegroups.com...
>
>> Currently for hundreds of such programs, I have to open each program one 
>> by
>> one and then click to print each one by one... very time consuming...
>
> Remember, these are simple text files.  You don't have to open them
> using the matlab editor.   Use any editors you like.
>
> If you're in linux, you can simply concatenate them together using the
> 'cat' command.  If you're not in linux, I suggest learning the Perl
> language (even if you are in linux, I suggest this).    Perl can help
> you deal with multiple text files in intelligent ways.  It's not easy
> to learn though, but the initial time invested is so much worth it in
> the long run.   I've probably saved hundreds of hours alone by using
> perl for various tasks such as what you describe.
>
> In general a logical approach would be to order the filenames in order
> of appearance within the code.
> If A.m calls A1.m and A2.m, and A1.m  calls A1a.m and A1b.m, you'd
> have
>
> A.m
> A1.m
>  A1a.m
>  A1b.m
> A2.m
> B.m
> ...
> then concatenate these together, convert to postscript or pdf (linux:
> man enscript, windows: MS Word/Open office Writer), then print.
>

Okay, perhaps an easier way is to find all the Matlab files under one 
directory and print them out...

(since when I develop programs, I put them all under local directory...)

How to do that? 


0
Reply housing2006 (283) 4/22/2007 5:34:52 PM

Mike wrote:
> "Ben" <jbenjam@gmail.com> wrote in message 
> news:1177234602.385073.230950@n59g2000hsh.googlegroups.com...
>>> Currently for hundreds of such programs, I have to open each program one 
>>> by
>>> one and then click to print each one by one... very time consuming...
>> Remember, these are simple text files.  You don't have to open them
>> using the matlab editor.   Use any editors you like.
>>
>> If you're in linux, you can simply concatenate them together using the
>> 'cat' command.  If you're not in linux, I suggest learning the Perl
>> language (even if you are in linux, I suggest this).    Perl can help
>> you deal with multiple text files in intelligent ways.  It's not easy
>> to learn though, but the initial time invested is so much worth it in
>> the long run.   I've probably saved hundreds of hours alone by using
>> perl for various tasks such as what you describe.
>>
>> In general a logical approach would be to order the filenames in order
>> of appearance within the code.
>> If A.m calls A1.m and A2.m, and A1.m  calls A1a.m and A1b.m, you'd
>> have
>>
>> A.m
>> A1.m
>>  A1a.m
>>  A1b.m
>> A2.m
>> B.m
>> ...
>> then concatenate these together, convert to postscript or pdf (linux:
>> man enscript, windows: MS Word/Open office Writer), then print.
>>
> 
> Okay, perhaps an easier way is to find all the Matlab files under one 
> directory and print them out...
> 
> (since when I develop programs, I put them all under local directory...)
> 
> How to do that? 
> 
> 

on linux there exists the very useful program enscript. it also does 
code highlighting (however, i do not know in the case of matlab) and 
very nice things, such as borders and headings, multicolumn, ...



michael
0
Reply themiwi.REMOVE.THIS (862) 4/22/2007 5:51:32 PM

"Michael Wild" <themiwi.REMOVE.THIS@student.ethz.ch> wrote in message 
news:462ba0a3$1@news1.ethz.ch...
> Mike wrote:
>> "Ben" <jbenjam@gmail.com> wrote in message 
>> news:1177234602.385073.230950@n59g2000hsh.googlegroups.com...
>>>> Currently for hundreds of such programs, I have to open each program 
>>>> one by
>>>> one and then click to print each one by one... very time consuming...
>>> Remember, these are simple text files.  You don't have to open them
>>> using the matlab editor.   Use any editors you like.
>>>
>>> If you're in linux, you can simply concatenate them together using the
>>> 'cat' command.  If you're not in linux, I suggest learning the Perl
>>> language (even if you are in linux, I suggest this).    Perl can help
>>> you deal with multiple text files in intelligent ways.  It's not easy
>>> to learn though, but the initial time invested is so much worth it in
>>> the long run.   I've probably saved hundreds of hours alone by using
>>> perl for various tasks such as what you describe.
>>>
>>> In general a logical approach would be to order the filenames in order
>>> of appearance within the code.
>>> If A.m calls A1.m and A2.m, and A1.m  calls A1a.m and A1b.m, you'd
>>> have
>>>
>>> A.m
>>> A1.m
>>>  A1a.m
>>>  A1b.m
>>> A2.m
>>> B.m
>>> ...
>>> then concatenate these together, convert to postscript or pdf (linux:
>>> man enscript, windows: MS Word/Open office Writer), then print.
>>>
>>
>> Okay, perhaps an easier way is to find all the Matlab files under one 
>> directory and print them out...
>>
>> (since when I develop programs, I put them all under local directory...)
>>
>> How to do that?
>
> on linux there exists the very useful program enscript. it also does code 
> highlighting (however, i do not know in the case of matlab) and very nice 
> things, such as borders and headings, multicolumn, ...
>
>
>
> michael

How about Matlab and on Windows XP?

Thanks 


0
Reply housing2006 (283) 4/23/2007 4:12:55 AM

Mike wrote:
> "Michael Wild" <themiwi.REMOVE.THIS@student.ethz.ch> wrote in message 
> news:462ba0a3$1@news1.ethz.ch...
>> Mike wrote:
>>> "Ben" <jbenjam@gmail.com> wrote in message 
>>> news:1177234602.385073.230950@n59g2000hsh.googlegroups.com...
>>>>> Currently for hundreds of such programs, I have to open each program 
>>>>> one by
>>>>> one and then click to print each one by one... very time consuming...
>>>> Remember, these are simple text files.  You don't have to open them
>>>> using the matlab editor.   Use any editors you like.
>>>>
>>>> If you're in linux, you can simply concatenate them together using the
>>>> 'cat' command.  If you're not in linux, I suggest learning the Perl
>>>> language (even if you are in linux, I suggest this).    Perl can help
>>>> you deal with multiple text files in intelligent ways.  It's not easy
>>>> to learn though, but the initial time invested is so much worth it in
>>>> the long run.   I've probably saved hundreds of hours alone by using
>>>> perl for various tasks such as what you describe.
>>>>
>>>> In general a logical approach would be to order the filenames in order
>>>> of appearance within the code.
>>>> If A.m calls A1.m and A2.m, and A1.m  calls A1a.m and A1b.m, you'd
>>>> have
>>>>
>>>> A.m
>>>> A1.m
>>>>  A1a.m
>>>>  A1b.m
>>>> A2.m
>>>> B.m
>>>> ...
>>>> then concatenate these together, convert to postscript or pdf (linux:
>>>> man enscript, windows: MS Word/Open office Writer), then print.
>>>>
>>> Okay, perhaps an easier way is to find all the Matlab files under one 
>>> directory and print them out...
>>>
>>> (since when I develop programs, I put them all under local directory...)
>>>
>>> How to do that?
>> on linux there exists the very useful program enscript. it also does code 
>> highlighting (however, i do not know in the case of matlab) and very nice 
>> things, such as borders and headings, multicolumn, ...
>>
>>
>>
>> michael
> 
> How about Matlab and on Windows XP?
> 
> Thanks 
> 
> 


I think enscript is available for cygwin. But on Windows you might also 
opt for latex with the listings package. I know that listings does 
matlab pretty printing and highlighting. To write a small (matlab?) 
program which fills in a latex template is quite easily achieved. I did 
it once and it worked like a charm. To spice things up you might also 
consider using the package fancyheader.

Michael
0
Reply themiwi.REMOVE.THIS (862) 4/23/2007 6:23:54 AM

5 Replies
78 Views

(page loaded in 0.134 seconds)

Similiar Articles:













7/28/2012 5:28:46 AM


Reply: