matlab - Alternatives to `clear(function_name)` to remove function from RAM? -
as stated in matlab's faq,
1.3.3.1. why, when edit function file in matlab, change not seen matlab until cleared or matlab restarted?
when write m-file in matlab, can either write script or function. difference script read disk , parsed line line each time called. function loaded ram execution. because loaded ram, when edit function, change not loaded ram until call new function made.
to matlab recognize edited function, type
clear functions clear functions, or clear <function name> clear function out of ram.
this major pain when i'm developing function & editing repeatedly (i use external editor of time). thinking of putting in final line, @ least during debug, like
clear(myfunc)
but i'm concerned unwanted side effects. know if there any?
further, i'd rather have way configure matlab doesn't automatically store called functions in ram once top-level function (i.e. 1 called console) terminates. possible?
edit: should mention matlab's behavior inconsistent. edits take effect once save m-file, other times don't even if i'm editing matlab ide editor window.
in honesty matlab has powerful editor should using it. make life easier. (just opinion)
unless running code stepping through no change code run until code re-run (preferably cleared workspace).
clear(myfunc)
clear variables created function in upto point. can add @ end of function or scriptclear variablea variableb
variables want cleared @ end. give control clear want. once variables cleared effect if variables called again later in code error occur since no longer exist.if testing particular function , want save time not calling inputs each time , want clear workspace , command window @ same time. can add following code beneath function definition.
if leave following code , call function function or script, code ignored long inputs available externally. add if statement occur when call function no inputs doc nargin. add top level function , press run button or f5 without having type in command window run code.
function [ output1, output2 ] = blah( input1, input2 ) if nargin == 0 clc clear %above 2 lines clear workspace , command window when run %the function %define function inputs %(optionally add following behave if inserted breakpoint %in location before error occurred (great debugging) db stop if error end
*you can add short-cut snippets of code in top right of matlab interface clear workspace etc when clicked.
Comments
Post a Comment