Save part of a big matrix to *.mat of another name

1 次查看(过去 30 天)
Hi,
Now I have a 3D matrix: abc = rand(2,3,3); I want to save only the second layer of the matrix abc(2,:,:) to the workspace, with the name of, e.g. new.mat
Matlab accepts the following code: save('new.mat', 'abc')
But not save('new.mat', 'abc(2,:,:)')
What should I do? any suggestion is appreciated!

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2012-10-18
abc = rand(2,3,3);
abc2=abc(2,:,:)
save('new.mat', 'abc2')
  2 个评论
Pengfei
Pengfei 2012-10-18
Hi, thanks. But for my case, the abc matrix is huge, and I have to be very frugal about the memory. Making a copy like abc2=abc(2,:,:) will take more space and lower the speed for the code.
Azzi Abdelmalek
Azzi Abdelmalek 2012-10-18
I suggest
abc = rand(2,3,3);
abc2=abc(2,:,:)
abc(2,:,:)=[]
save('new.mat', 'abc2')
or if you don't need abc
clear abc % just before saving abc2

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by