bugGNU Octave - Bugs: bug #54722, Publishing document with sections...


bug #54722: Publishing document with sections does not carry over variables

Submitted by:  STPR <theillusiveman>
Submitted on:  Tue 25 Sep 2018 02:19:08 AM UTC  
Category:  Octave Function Severity:  3 - Normal
Priority:  3 - Low Item Group:  Unexpected Error
Status:  Fixed Assigned to:  Kai Torben Ohlhus <siko1056>
Originator Name:  Open/Closed:  Closed
Release:  4.4.1 Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Tue 25 Sep 2018 11:22:07 PM UTC, comment #2: 

Thank you, it seems to be working fine!

STPR <theillusiveman>
Tue 25 Sep 2018 09:22:06 AM UTC, comment #1: 

Thank you for reporting this bug.  In the upcoming version of Octave, the publish function has been overhauled and uses an improved method to store the variables and solves your problem publishing the given script.

See changeset http://hg.savannah.gnu.org/hgweb/octave/rev/af43eb4e6502
for details.

As publish is a pure m-File, you can even now get in the comfort of this new function.  Just download the recent publish m-File:


and replace it in you current Octave installation, for example in


Can you report back here, if this works for you?

Kai Torben Ohlhus <siko1056>
Project MemberIn charge of this item.
Tue 25 Sep 2018 02:19:08 AM UTC, original submission:  

I recently realised that octave has a publish() function. I was trying to see if I could publish some scripts from my research in Octave. It appears to me that if your script contains sections (separated by %%), then any variable or function declared in any previous section is not available to the following sections. .

As an example, put the following lines in a script and publish the script:

close all;
%% 1. Plot a Sin()

myFun = @(t) sin(2*pi*2*t);
fs = 100;
t = (0:99)/fs;
x = myFun(t);
plot(t, x);
%% 2. Plot Sin^2()
y = myFun(t).^2;
plot(t, y);

This would generate an HTML file with the following error:

2. Plot Sin^2()

y = myFun(t).^2;
plot(t, y);

error: 't' undefined near line 3 column 11
y = myFun(t).^2;
plot(t, y)

It appears to me as if each section is run independently when being published. However, just running the script results in no issues. Publishing the same script in MATLAB works without any problems.

STPR <theillusiveman>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

   bug dependencies.


Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by theillusiveman (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-09-26 siko1056 StatusWorks For Me => Fixed
        Open/ClosedOpen => Closed
    2018-09-25 siko1056 Dependencies- => bugs #54723 is dependent
    2018-09-25 siko1056 Priority5 - Normal => 3 - Low
        StatusNone => Works For Me
        Assigned toNone => siko1056

    Back to the top

    Powered by Savane 3.5