matfile function for multidimentional arrays
조회 수: 2 (최근 30일)
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!