Matlab class array / other array

In summary, the line of code "snleg = strtrim(cellstr(num2str(alf_deg.')))" is used to remove any leading and trailing white spaces from a file that has been scanned in. The function uses the arguments cellstr and num2str to convert the variable alf_deg, which is already initialized in the code, into a string value. The .' at the end of the code returns the transpose of the matrix alf_deg.
  • #1
K41
94
1
Okay so what does this line of code mean:

snleg = strtrim(cellstr(num2str(alf_deg.')));

I did some research and it is ultimately removing whitespace (comma's, spaces etc) from a file scanned in, but I don't understand the argument of the function.

I don't understand what cellstr is or num2str. I read that it might be to do with cell arrays and they can't or can be modified? I am very confused :sI imagine num2str converts a number to a string value but why do we need to do this?

Please note, alf_deg was a variable already initialized in the code. Why do we need a .' in here?
 
Physics news on Phys.org
  • #2

1. What is the difference between a Matlab class array and other array types?

Matlab class arrays are a type of array that are specifically designed for use in the Matlab programming language. They are dynamic, meaning they can change in size as needed during program execution. Other array types, such as static arrays, have a fixed size and cannot be changed during execution.

2. How do I create a Matlab class array?

To create a Matlab class array, you can use the "array" function and specify the size and data type of the array. For example, to create a 3x3 array of integers, you would use the command "myArray = array('int32', [3 3]);".

3. Can I mix different data types in a Matlab class array?

Yes, Matlab class arrays allow for mixing of different data types within the same array. This can be useful for storing and manipulating different types of data in a single variable.

4. How do I access elements in a Matlab class array?

Elements in a Matlab class array can be accessed using index notation. For example, to access the element at the second row and third column, you would use the command "myArray(2, 3)".

5. Are there any limitations to using Matlab class arrays?

One limitation of Matlab class arrays is that they can only hold up to 2^31-1 elements. Additionally, they may not be suitable for large datasets or complex data structures, in which case other data structures may be more efficient.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
742
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
Back
Top