필터 지우기
필터 지우기

the command "clc" and "clear all" does not work on a script in the editor.

조회 수: 60 (최근 30일)
Artur M. G. Lourenço
Artur M. G. Lourenço 2012년 7월 12일
댓글: Rik 2021년 10월 6일
The commands "clc" and "clear all" don't work in my script, somentimes yes.
i have matlab 2011 a and b e 2012 a.
  댓글 수: 2
khursheed ansari
khursheed ansari 2018년 1월 16일
Click the cursor anywhere in command window then press "Ctlr+C" then use "clc" and "clear all" will work
Steve da Silva Ferreira
Steve da Silva Ferreira 2020년 12월 13일
Hi, Artur, had a similar problem with clc and clear all not working. Realised, that I was in a for , or if statement, so, clc and clear won't work in there. Make sure, that you end those statements, which will return you back to the ( >>) section, you do not want to use clc and clear, where there are no >> ie. Just blank line.
Hope this helps 😁

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

답변 (6개)

Gkhn Gny
Gkhn Gny 2017년 4월 1일
편집: Gkhn Gny 2017년 4월 1일
I have the same issue at some scripts, I dont know the reason.
But this is working in every case
evalin('base','clear')
  댓글 수: 1
Steven Lord
Steven Lord 2017년 4월 1일
That suggests you've created a variable named clear. While there's a variable named clear in the workspace, you can't call the clear function without some indirect approach like that.

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


Greg Heath
Greg Heath 2012년 7월 12일
They are not defined to work in the editor.
They work on the command line and when the corresponding script or function is executed

Artur M. G. Lourenço
Artur M. G. Lourenço 2012년 7월 12일
inglêsportuguêsespanhol
I found that putting too many comments before or after the command "clc" and "clear all" in the script, they do not work.
It happens to someone?
  댓글 수: 5
Image Analyst
Image Analyst 2012년 7월 12일
I can't reproduce. It works fine for me.
Artur M. G. Lourenço
Artur M. G. Lourenço 2013년 5월 26일
Hi guys I do not know why, but I found that when placed at the beginning of a script "clear all" and "clc" using the ANN toolbox (Neural) occurred a bug and the variables in my workspace were not clean, the problem was this. I now use the 2013 and all is well! Thank you all!

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


Walter Roberson
Walter Roberson 2012년 7월 13일
Exactly what is it that you think that "clc" and "clear all" do ?
If someone is requiring that you put in clc and "clear all", such as if you will fail an assignment if you do not put them in, then just go ahead and put in and do not worry about what they do or do not do under any particular circumstances. If someone requires that you put them in, then that person is taking responsibility for any program failure that might result.
If no-one is requiring that you put in clc and "clear all", then eliminate any problems with them by simply not putting them in.
"Doctor, doctor, every time I drink a cup of coffee I get a sharp pain in my nose."
"Have you tried taking the spoon out of the cup?"
  댓글 수: 2
Vishnu Keyen
Vishnu Keyen 2021년 10월 6일
Something like this I want
for i = 1:10
fprintf('iterantion %d --> %1.3f\n',i,randn(1));
pause(1);
clc
end
iterantion 1 --> -0.687 iterantion 2 --> -0.603 iterantion 3 --> -0.800 iterantion 4 --> -0.001 iterantion 5 --> -0.662 iterantion 6 --> -1.583 iterantion 7 --> 1.089 iterantion 8 --> 1.939 iterantion 9 --> 0.490 iterantion 10 --> -1.094
I want to delete the previous display of number and then display the new number only.
But this runs without clearing, so i get 10 lines of printed output, I just want 1
Rik
Rik 2021년 10월 6일
@Vishnu Keyen This is a question, not a comment to an answer. Have a read here and here. It will greatly improve your chances of getting an answer.
You have two options:
  1. Use clc (which doesn't work as expected in the web environment, as you can see).
  2. Count the number of characters you printed and print as many backspace characters.

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


Artur M. G. Lourenço
Artur M. G. Lourenço 2013년 5월 26일
I was misunderstood in my question or did poorly.
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 5월 26일
I don't think you were misunderstood, but we are having difficulty believing it. Unless, that is, you had the "clear all" within a script that was being invoked from something else: if that is what is happening then it wouldn't surprise us at all that you had the problem.

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


Greg Heath
Greg Heath 2013년 5월 26일
HEY!
Why are you using the answer box for your questions and comments?
Just so you can accept your own question as the correct answer?
Since my answer was the first correct one, YOU OWE ME!
Greg
  댓글 수: 3
Jan
Jan 2013년 5월 26일
@Eng_Amb: Who is niguem? I do not see the anything in this thread, which implies a Matlab bug. Your problem has not become clear to me yet and the opinion, that there is a connection to the number of comments before and after the the command is obviously wrong.
Artur M. G. Lourenço
Artur M. G. Lourenço 2013년 5월 27일
sorry "ninguem" is anybody. So I will try to explain as best as possible. When I write a code in the editor I put "Clear all" and "clc" to clear the variables in the workspace and something written in the command window. When put many comments in my code, simply "Clear all" and "clc" did not work. I do not know why. I used the ANN toolbox. I used the 2012 version, but now I have to 2013 and everything is working normally. I will give you my code for you to open and test if you have matlab 2012.
https://docs.google.com/file/d/0B9JmyPHF_ZMPcDNNU1VIV01iakU/edit?usp=sharing
Is solved now, thank you all for the help.

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

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by