MATLAB Reshaping Multi-Dimensional Arrays in MATLAB

  • Thread starter Thread starter short circut
  • Start date Start date
  • Tags Tags
    Matlab
AI Thread Summary
The discussion centers on manipulating a 15x15x4001 matrix in MATLAB to track a specific element over time. The user encounters an issue where extracting an element using mystruct(1,1,:) returns a 1x1x4001 structure, while the desired output format is either 4001x1 or 1x4001. To achieve this without using a for loop, the user is advised to utilize the reshape function, specifically reshape(mystruct(1,1,:), 1, 4001) or reshape(mystruct(1,1,:), 4001, 1). Additionally, the shiftdim function is suggested as an alternative solution. The user acknowledges the challenge of navigating MATLAB's extensive documentation.
short circut
Messages
16
Reaction score
0
Ok so here is the problem
I have a 15x15x4001 structure. Basically it is a matrix at 4001 time points.
I want to track one element at a time as a function of time

the problem is that

mystruct(1,1,:)

is being read as a 1x1x4001 structure
I want it to read in as either 4001x1 or 1x4001

How can I do this without making a for loop to convert each one individually?

If MATLAB doesn't have a built in function for this I can make one but it should already have that functionality built in.
 
Physics news on Phys.org
Thank you. I wasnt even sure what to look for in the documentation. I did look there before I asked. I promise.
 

Similar threads

Replies
32
Views
4K
Replies
5
Views
3K
Replies
1
Views
2K
Replies
2
Views
1K
Replies
1
Views
1K
Replies
3
Views
1K
Back
Top