How can I hide all variables in work space to display ?

조회 수: 17 (최근 30일)
Koustubh Shirke
Koustubh Shirke 2020년 3월 13일
댓글: Koustubh Shirke 2020년 3월 13일
Hi,
I have created one script (not a function). While runnign the script , I dont want to showcase the variables in workspace.
How can I do it in matlab ? I am planning to create p.code of that lateron,
Regards,
Koustubh
  댓글 수: 1
Stephen23
Stephen23 2020년 3월 13일
"How can I do it in matlab ?"
Simple: use a function, not a script.
Scripts are fun for playing around with, but I would not use them for any code that is used for longer than one day.

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

답변 (1개)

John D'Errico
John D'Errico 2020년 3월 13일
편집: John D'Errico 2020년 3월 13일
Um, then don't make it a script? Scripts are something worth learning to avoid as you progrees further into MATLAB anyway. But if you don't want what you write to leave behind a slew of variables, then don't make it a script!
If you will give this code to someone else, note that it will step on any variables that are already in their base workspace - a bad thing.
I did check, by the way, to verify that you can indeed p-code a script. Why, oh why would you do that, I don't know. But you can do so.
Yes, I suppose you could put one line at the end of your script, that just clears all of the variables, but why in the name of god and little green apples would you do that, when all you need to do is learn to use a function? If you did as I just said anyway, then note that if the user does have a variable with the same name as something you just created, then it will overwrite their work, and then you will delete it. This is a bad thing.
Yes. I do often create little scripts myself, usually purely as temporary things, to test out a block of code, etc. But for anything I would ever give to someone else, it would NEVER be in script form.
Just learn to use functions!!!!!!!!!
  댓글 수: 6
Stephen23
Stephen23 2020년 3월 13일
@Koustubh Shirke: using a function is the easy solution.
Koustubh Shirke
Koustubh Shirke 2020년 3월 13일
@stephen Thank you

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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by