Filter löschen
Filter löschen

How many variables in workspace

73 Ansichten (letzte 30 Tage)
Marco Castelli
Marco Castelli am 28 Dez. 2012
Kommentiert: Tobias Kern am 9 Apr. 2021
Hi, I need a function how return the number of variables in the Workspace. Does Someone knows if this function exists?
thanks Marco
  3 Kommentare
Image Analyst
Image Analyst am 28 Dez. 2012
I couldn't think of any reason either. I figured it must be something like fdep, though somewhat different - for variables instead of functions and classes.
Walter Roberson
Walter Roberson am 28 Dez. 2012
Bearbeitet: Walter Roberson am 28 Dez. 2012
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 28 Dez. 2012
Bearbeitet: Image Analyst am 28 Dez. 2012
variablesInCurrentWorkspace = who
numVariables = length(variablesInCurrentWorkspace)

Weitere Antworten (1)

JP  Hadden
JP Hadden am 15 Mär. 2017
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 Kommentar
Walter Roberson
Walter Roberson am 15 Mär. 2017
Bearbeitet: Walter Roberson am 15 Mär. 2017
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by