Hi,
I want to remove all variables from command history except specified variables in Matlab 6p5, but I use: clearvars -except D F
But it gives an error, please someone help how to use this? or which function is equal to?

5 Kommentare

Rik
Rik am 21 Dez. 2017
There is a big difference between workspace and command history. Which do you mean?
Stephen23
Stephen23 am 21 Dez. 2017
Bearbeitet: Stephen23 am 21 Dez. 2017
"I want to remove all variables from command history"
The command history stores a simple list of commands and operations that have been run, and does not contain any variables. The workspace contains variables, and can be cleared if so desired (but usually there is no point, especially when calling functions).
These kind of basic concepts are explained in the MATLAB introductory tutorials (which are recommended for all beginners):
Rik
Rik am 21 Dez. 2017
Also, if there isn't a good reason to stick to a 15 year old release, I would recommend updating to a newer release. Some of my functions have a 70% run time reduction even between R2012b and R2017b.
Jan
Jan am 21 Dez. 2017
Bearbeitet: Jan am 21 Dez. 2017
Matlab 6.5 is damn fast.
  • Time from double click on the desktop icon until Matlab's desktop is ready to use:
Matlab 6.5: 1.5 sec
Matlab 2016b: 17 sec
  • First opening of a medium size GUI containing 76 UICONTROLs, 2 small images and an empty axes (programmatic creation, not GUIDE):
Matlab 6.5: 2.0 sec
Matlab 2016b: 10.2 sec
  • For subsequent starts of the GUI, the processing is much faster:
Matlab 6.5: 0.3 sec
Matlab 2016b: 0.8 sec
  • A 3D animation (20 lines, 10 arrows, 20 small spheres, 2 squares which are semi-transpaent under OpenGL, background, a time counter as UICONTROL) in a self test using all different renderers:
Matlab 6.5: 29 sec
Matlab 2016b: 63 sec
NOTE: This Matlab 6.5 runs in a virtual XP machine with 1 core, while R2016b uses a real machine with 2 cores and accelerated hardware OpenGL drivers.
Some of the numerical computations are a little bit faster due to multi-threading and modern MKL versions. But as soon as any graphics are used, the Java methods do not have any chance to compete with the direct usage of the graphic system of the operating system.
For a typical work process, I use Matlab to discuss a clinical measurement with a patient or physician. Therefore I open Matlab and start the GUI. Total time: 3.5 sec compared to 27 sec. Imagine the emotion of the person sitting in front of me, remember the golden rule: Every computing process, which takes longer then 5 sec, causes mental stress.
But of course I do not develop code in version 6.5! Never ever. MLint is extremely valuable. Who cares about 23 seconds startup time, when the modern version avoids weeks of debug time?! I insist on using catch with the MException object, therefore the current versions of my codes do not run under 6.5 anymore. But when I have a task, which needs a lot of time for graphical outputs (create PDF sheets with 3 pages a 12 diagrams, legends, statistics and some markers) for 1200 patients, I will definitely do this under 6.5, except I want to let it run over night.
6.5 was a lean and rock hard system. Modern Matlab's are much more marshmallowig: more fluff, more sweets, more ribbons, more energy, more threads. It was a good time with v6.5 on XP, but now we have almost 2018 - not the right decade to work with rock hand ax.
@Rik: You cannot extrapolate the acceleration between 2012b and 2017b to older versions. But your suggestion is correct: It is time for an update.
Rik
Rik am 22 Dez. 2017
@Jan thank you, you've opened my eyes. I'll keep it in mind for when I need to batch create graphical output. I have only started using Matlab from R2011b, so from there I have only seen speed increases (not caring about boot up time).

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Jan
Jan am 21 Dez. 2017

0 Stimmen

It is a bad programming practice to control the existence of variables by clear. Better use functions to keep the workspaces clean. But if you really want to do this: Search in the FileExchange for some submissions, which work with historical Matlab versions also:

4 Kommentare

Walter Roberson
Walter Roberson am 21 Dez. 2017
clearvars was not introduced until R2008a.
Mekala balaji
Mekala balaji am 21 Dez. 2017
Sir, but any other way to remove variables from workspace except specified variables?
Walter Roberson
Walter Roberson am 21 Dez. 2017
See the link Jan posted.
Walter Roberson
Walter Roberson am 22 Dez. 2017
And to be clear: in R6.5, there was no built-in way to clear everything except some variables.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by