Reshaping Multi-Dimensional Arrays in MATLAB

  • MATLAB
  • Thread starter short circut
  • Start date
  • Tags
    Matlab
In summary, the conversation discusses the issue of reading a 15x15x4001 matrix at 4001 time points and tracking one element at a time. The problem is that the matrix is being read as a 1x1x4001 structure instead of a 4001x1 or 1x4001 structure. The solution is to use the reshape function, specifically reshape(mystruct(1,1,:), 1, 4001) or reshape(mystruct(1,1,:), 4001, 1), or the shiftdim function.
  • #1
short circut
16
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
  • #3
Thank you. I wasnt even sure what to look for in the documentation. I did look there before I asked. I promise.
 

What is a Matlab dimensional problem?

A Matlab dimensional problem refers to an issue that arises when working with data or equations that have different units or dimensions. This can lead to errors in calculations or incorrect interpretations of results.

How does Matlab handle dimensional problems?

Matlab has a built-in unit system that allows for easy conversion between different units. It also has functions and tools that can help identify and resolve dimensional problems, such as the "unitconversion" function.

What are some common causes of dimensional problems in Matlab?

Some common causes of dimensional problems in Matlab include inputting data with inconsistent units, using incorrect or mismatched conversion factors, and using the wrong mathematical operations on values with different dimensions.

What is the best way to avoid dimensional problems in Matlab?

The best way to avoid dimensional problems in Matlab is to carefully check and double-check all inputs and units before running calculations. It can also be helpful to use comments and labels in the code to keep track of units and conversions.

Can dimensional problems in Matlab be fixed?

Yes, dimensional problems in Matlab can be fixed by identifying the source of the problem and making appropriate adjustments to the code. This may involve converting units, using the correct conversion factors, or using functions specifically designed to handle dimensional problems.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
859
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Back
Top