bugGNU Octave - Bugs: bug #40095, Clearvar function not implemented


bug #40095: Clearvar function not implemented

Submitted by:  None
Submitted on:  Tue 24 Sep 2013 02:02:42 PM UTC  
Category: Octave FunctionSeverity: 1 - Wish
Priority: 3 - LowItem Group: Matlab Compatibility
Status: Patch SubmittedAssigned to: None
Originator Name: FedericoOriginator Email: -unavailable-
Open/Closed: OpenRelease: dev
Operating System: Any

Add a New Comment(Rich Markup)

You are not logged in

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


(Jump to the original submission Jump to the original submission)

Fri 16 Mar 2018 07:06:04 PM UTC, comment #7:

OK I extended the test suite, fixed a couple of bugs and added the Octave copyright notice. Files are attached.

BTW I've checked the consistency with MATLAB behaviour which also passes (except the global variable test at the end which doesn't like definition/assignment on the same line and wants the function definition at the end of the file. However when I correct those incompatibilities it also passes).

So, this clearvars behaves just like MATLAB.

(file #43577, file #43578)

Ceral Paquet <octavebugs>
Fri 16 Mar 2018 12:45:34 PM UTC, comment #6:

I'd like to contribute this working implementation of clearvars.m based heavily on what David Turner did earlier. It has one minor bug relating to Octave's handling of ans in evalin (https://savannah.gnu.org/bugs/?53359).

Ceral Paquet <octavebugs>
Mon 11 Sep 2017 02:57:35 PM UTC, comment #5:

Updated local Windows Octave version to 4.2.1
I tried the patch saving it under C:\Octave\Octave-4.2.1\share\octave\4.2.1\m\general path and launched a script that uses clearvar function.

result is the following:
error: Invalid call to strjoin. Correct usage is:

-- STR = strjoin (CSTR)
-- STR = strjoin (CSTR, DELIMITER)
error: called from
print_usage at line 91 column 5
strjoin at line 56 column 5
clearvars at line 68 column 3
xxxxxxxxx at line 22 column 5

Is the patch out of date?

Federico Gennari <fedemone>
Tue 22 Nov 2016 10:03:44 PM UTC, comment #4:

The "clearvars" function is still missing in Octave 4.2.0.

This new function is submitted as a patch in comment #3.

Hartmut <hardy>
Fri 18 Dec 2015 10:37:55 AM UTC, comment #3:

Federico, the .m file in the changeset relies on the other changes to the C++ code.

The attached .m file runs with the current codebase.

(file #35789)

Lachlan Andrew <lachlan>
Project Member
Thu 20 Mar 2014 03:19:50 PM UTC, comment #2:

I tried with a pre-release version (octave-3.8.1-1) of Windows build found here:

and clearvars is still not present. Also, trying to use as .m file the patch kindly provided here is not working.

Why the fix has not been ported? Should we expect it in official Windows build?

Federico Gennari <fedemone>
Mon 30 Sep 2013 02:44:16 AM UTC, comment #1:

I've attached a patch for this (I also decided to patch the who function, because it didn't match what matlab did).

David M. Turner <novalis>
Tue 24 Sep 2013 02:02:42 PM UTC, original submission:

The function Clearvar existing in Matlab (and described here:
http://www.mathworks.it/it/help/matlab/ref/clearvars.html )is not implemented in Octave and not recognized, giving corectly an error message.

Such function is not present in Source Forge listing: http://octave.sourceforge.net/functions_by_alpha.php

Could it be implemented?



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

Attach File(s):

Attached Files
file #43580:  clearvars.m added by octavebugs (3KiB - text/x-objcsrc - Tidied up slightly. Use this version!)
file #43577:  clearvars.m added by octavebugs (3KiB - text/x-objcsrc)
file #43578:  test_clearvars.m added by octavebugs (1KiB - text/x-objcsrc)
file #35789:  clearvars.m added by lachlan (4KiB - text/x-objcsrc)
file #29264:  fix-40095 added by novalis (6KiB - application/octet-stream - Patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by octavebugs (Posted a comment)
  • -unavailable- added by hardy (Posted a comment)
  • -unavailable- added by mtmiller (Updated the item)
  • -unavailable- added by lachlan (Updated the item)
  • -unavailable- added by fedemone (Posted a comment)
  • -unavailable- added by jordigh (Updated the item)
  • -unavailable- added by novalis (Updated the item)
  • -unavailable- added by None (Submitted the item)

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

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 10 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 16 Mar 2018 07:33:17 PM UTCoctavebugsAttached File-=>Added clearvars.m, #43580
    Fri 16 Mar 2018 07:06:04 PM UTCoctavebugsAttached File-=>Added clearvars.m, #43577
      Attached File-=>Added test_clearvars.m, #43578
    Thu 31 Mar 2016 05:30:03 AM UTCmtmillerSeverity3 - Normal=>1 - Wish
      Priority5 - Normal=>3 - Low
      Operating SystemMicrosoft Windows=>Any
    Fri 18 Dec 2015 10:37:55 AM UTClachlanAttached File-=>Added clearvars.m, #35789
    Mon 30 Sep 2013 12:45:50 PM UTCjordighStatusNone=>Patch Submitted
    Mon 30 Sep 2013 02:37:18 AM UTCnovalisAttached File-=>Added fix-40095, #29264

    Back to the top

    Powered by Savane 3.1-cleanup1