Can I create multiple workspace with variables with the same name?

I need to create differents variables to do some activities but normally the variables are named with the same name, can I have more than one workspaces?

댓글 수: 2

Why so? Can you give example?
Stephen23
Stephen23 2019년 5월 2일
편집: Stephen23 2019년 5월 2일
"can I have more than one workspaces?"
Of course: every function instance has its own workspace:
Note that writing code where the variables' names are significant indicates weakness in the code design: variable names should not matter.
For your (totally unexplained task) you are probably much better off using functions, loops or code vectorization. Are you using scripts? If so, you really need to use functions:

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

답변 (1개)

s mohammad hosien abedy nejad
s mohammad hosien abedy nejad 2020년 8월 16일
편집: Jan 2020년 8월 16일
you can use structure also.
s(1).var1 = ....
s(2).var1 = ....
s(3).var1 = ....
for use s in other functions declare it as global

댓글 수: 1

Global variables cause more problems, than they solve. But a struct is a good solution here.

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

카테고리

도움말 센터File Exchange에서 Structures에 대해 자세히 알아보기

질문:

2019년 5월 2일

댓글:

Jan
2020년 8월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by