matfile function for multidimentional arrays
2 views (last 30 days)
Show older comments
Hello everyone,
I am working on a code to express a field as an expansion of multipoles (6D arrays) to interact with a large number of particles. In this work, I have worked with arrays larger than 10GB. Currently, I am attempting to save the large variables into .mat files, read specific parts of the array that I require, modify them, and save them again in the large .mat file. However, I have encountered difficulties in achieving this. Let me simplify my problem to the following situation:
clear;
clc;
%% Parameters
lambda0=532e-9;
n_s=1.33;
ks=2*pi*n_s/lambda0;
r=7.5e-6;
L_max=10;
Mmax = 2*L_max + 1;
theta=linspace(1e-4,pi,111);
phi = linspace(0,2*pi,111);
[Theta,Phi]=meshgrid(theta,phi);
JJ=complex(zeros([2,L_max+1,Mmax,size(Theta),3]));% this is the big array I will be filling
A=ones(111,111,3); % here really I will use a function with do some operations but, its
% dimentions are (size(Theta),3)
save JJ.mat JJ -v7.3;
J=matfile('JJ.mat','Writable',true);
l=1;
m=2;
m_=1;
J.JJ(1, l+1, m+1, :, :,:) = A;
I understand that the issue lies in the dimensions of J.JJ, which is 2x11x21x111x111x3, while A has dimensions of 111x111x3. However, I still need to perform the required modifications. Specifically, I need to change the elements (1, l+1, m+1, :, :,:) of the JJ array to match the corresponding elements in array A. I am capable of accomplishing this task with a smaller array without utilizing matfile. However, considering the size of the array I am working with, do you have any ideas or suggestions on how to proceed?
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!