Matlab: Appending numbers as strings to a variable name

Click For Summary
SUMMARY

This discussion addresses the challenge of dynamically creating variable names in Matlab for radar data structures. The user seeks a method to append a number to a variable name to represent different data volumes, but is advised against this approach. Instead, the recommended solution is to utilize an array of structures, such as Volume(1) and Volume(2), to efficiently manage multiple volumes without prior knowledge of their count. This method simplifies data handling and adheres to Matlab's best practices.

PREREQUISITES
  • Understanding of Matlab data structures
  • Familiarity with arrays and indexing in Matlab
  • Basic knowledge of radar data collection methods
  • Experience with struct data types in Matlab
NEXT STEPS
  • Explore Matlab's array of structures functionality
  • Learn about dynamic field names in Matlab structures
  • Research best practices for managing large datasets in Matlab
  • Investigate Matlab's data visualization techniques for radar data
USEFUL FOR

Matlab users, data scientists, and engineers working with radar data who need efficient methods for managing variable structures without prior knowledge of data volume counts.

Meteochick
Messages
2
Reaction score
0
Hello,

I am wondering if it is possible to append a number as a string to the end of a variable name in Matlab? I am working with radar data and want to create structures for each volume of data, but I do not know how many volumes are contained in each file, and I have so many files I do not want to have to go through and count each of them! Here's an explanation of my data and what I'm trying to do.

Velocity and reflectivity data are collected at a specific number of range points, over a series of azimuth angles which is repeated over a known number of elevation angles. The grouping of range, azimuth, elevation is what I am calling a volume. Each data file I am dealing with contains 5 minutes worth of data, but the number of volumes collected is not constant because the number of elevations or azimuth angles can change from file to file. I want to create structures for each of the volumes within the file so that I have something like: Volume1 =struct('El1',{Elevation_Angles},'Range1',{Ranges},'V1',{Velocity_data},'Ref1',{Reflectivity_data}, Volume2=(The same thing except for the next volume)...

Is it possible to have some representation of the count of the volumes and append to the variable name 'Volume' so that I can create these different structures without needing prior knowledge of the number of volumes? (i.e. something like Volume($count), as it would be in a c-shell script?) OR, is there a better way of doing what I'm trying to do here without needing separate structures?

Thanks so much!
 
Physics news on Phys.org
You can use an array of structures. Like
Volume(1) = struct('El', Elevation_Angles, 'Range', Ranges, 'V', Velocity_data, 'Ref', Reflectivity_data)
Volume(2) = struct('El', Elevation_Angles, 'Range', Ranges, 'V', Velocity_data, 'Ref', Reflectivity_data)

etc
Basically, just put the number in parenthesis after Volume instead of trying to append it as a string.
 
Last edited:
That makes sense! Thanks a lot, I'll give it a try!
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
8K
  • · Replies 2 ·
Replies
2
Views
5K
Replies
5
Views
2K
Replies
1
Views
4K
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K