MATLAB Answers

How many variables in workspace

조회 수: 109(최근 30일)
Marco Castelli
Marco Castelli 2012년 12월 28일
댓글: Tobias Kern 2021년 4월 9일
Hi, I need a function how return the number of variables in the Workspace. Does Someone knows if this function exists?
thanks Marco
  댓글 수: 3
Walter Roberson
Walter Roberson 2012년 12월 28일
From the title I thought perhaps the question was going to be what the maximum number of variables in a workspace is. The answer to that appears to be 65533.

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

채택된 답변

Image Analyst
Image Analyst 2012년 12월 28일
편집: Image Analyst 2012년 12월 28일
variablesInCurrentWorkspace = who
numVariables = length(variablesInCurrentWorkspace)
  댓글 수: 1
Tobias Kern
Tobias Kern 2021년 4월 9일
length(who)

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

추가 답변(1개)

JP  Hadden
JP Hadden 2017년 3월 15일
For the responders, I have a situation where this is useful... we have an RSA which spits out matlab files where there can be a different number of data variables depending on the measurement. It 's useful to know how many there are to be able to analyse them.
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 3월 15일
What is an "RSA" in this context?
Does it output MATLAB code? If so then could it be modified to output the variables as structure members instead of independent variables?
If it outputs .mat files then those can be load()'d with an output argument, producing a structure.
With a structure, you can ask about the length of the fieldnames.
If you are working with dynamically generated full variable names, you probably want to avoid that.

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

Community Treasure Hunt

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

Start Hunting!

Translated by