2 views (last 30 days)

Hello!

I currently have a hundred or so large datasets that are MxN (thus 2-D), for the external program that I use to gather this information I must run it for each of the parameters that I'm changing, for example ... etc. Therefore I now have hundreds of MxN datasets that need to be combined into a multi-dimensional array. To give an example:

What I currently have:

data(alpha,mach) = 15; % element of the data at specified alpha and mach, for delta1 = 0; delta2 = 0; delta3 = 0; delta4 = 0;...

data(alpha,mach) = 10; % element of the data at specified alpha and mach, for delta1 = 5; delta2 = 0; delta3 = 0; delta4 = 0;...

Now I would like to have

data(alpha,mach,0,0,0,0,...) = 15;

data(alpha,mach,5,0,0,0,...) = 10;

I've looked into the "cat" command, but I'm not 100% on how it works, and how to check that the data that I've combined retains the same information.

Any help would be greatly appreciated!

Matt J
on 4 Apr 2020

Edited: Matt J
on 4 Apr 2020

If your "datasets" really are in the form of the Matlab dataset type described here, then I think you could probably just do something like the following:

C=dataset2cell(data); %convert the datasets to cell array

[m,n,p,q,r,s,t]=deal(10,12,5,5,5,5,5); %The data dimensions

dataArray = reshape( cat(3,C{:}) , [m,n,p,q,r,s,t]);

gridVectors ={alphaList,machList,delta1List,....}; %List of sample grid values for each of the variables

lookupFunction=griddedInterpolant(gridVectors,dataArray);

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 9 Comments

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_820776

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_820776

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_820835

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_820835

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_820845

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_820845

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_821020

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_821020

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_821233

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_821233

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_821244

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_821244

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_821399

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_821399

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_821403

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_821403

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_821407

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/515128-creating-a-multi-dimensional-array-out-of-many-lower-dimensional-arrays#comment_821407

Sign in to comment.