필터 지우기
필터 지우기

Simple clear script

조회 수: 11 (최근 30일)
sco1
sco1 2011년 4월 22일
Hello all,
I feel a little silly asking this question, but I'm trying to write a little one-line function to clear out my interface to help me while I'm writing and debugging code. All the function does is run clear;clc;close; so I don't have to type that in every time.
function cc
clear;clc;close;
However, the function won't clear any variables that exist outside of the function, which makes sense, but I can't figure out how to work around this.
For example:
test = [1 4 52 45 131 5 3]; figure; cc;
This successfully clears the command window and closes the figure, but does not clear test from the workspace. Is there any way around this? I tried clear all and clear global, but obtained the same result.
Thanks,
-Sam

채택된 답변

Chirag Gupta
Chirag Gupta 2011년 4월 22일
don't make it a function
Just let it be a MATLAB script (Then it will run in the scope its called)
Currently, since its a function, it runs in the function scope
clear;clc;close;
save as cc.m should do the trick
  댓글 수: 2
sco1
sco1 2011년 4월 22일
Geesh, I figured it would be something this simple.
I remember it working when I first made it but couldn't figure out why it wasn't working any more. It never dawned on me that it was because I made it into a function.
sco1
sco1 2011년 4월 22일
Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Automated Driving Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by