Random save two large matrices in the same manner?

6 Ansichten (letzte 30 Tage)
Salem
Salem am 16 Nov. 2014
Kommentiert: Salem am 16 Nov. 2014
I have a matrix M1 and a vector M2. M1 is 4d matrix sized [150*150*3*9000] and the vector M1 is [9000*1]. Both of them saved using this command, save ('data. mat','M1','M2','-7,3'). I want to save the data randomly in both M1 & M2 but I need the rows in both M1 & M2 go together because M1 is the labeled or value of the images in M2. I tried many code, but after the change I found new rows in M2 is pointing to new rows in M1 which change the labels of the data. I tried for loop, but I've gone out of memory. So, could someone please share with me some an efficient code or way to do like this operation. Thanks in advanced.
  2 Kommentare
Guillaume
Guillaume am 16 Nov. 2014
What do you mean by save the data randomly. You either save a variable or you don't.
Do you mean you want to save only part of the matrices at random? Or save a random permutation of the matrix? Or something else?
Also, please don't add irrelevant tags and products. Your question has nothing to do with image processing or parallel toolbox.
Salem
Salem am 16 Nov. 2014
Bearbeitet: Salem am 16 Nov. 2014
Thanks Guillaume,
Thanks for replying. I want to save the variables in the matrix randomly. like
Sorry for adding irrelevant tags and products, I though images may is related because this matrix are images.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

the cyclist
the cyclist am 16 Nov. 2014
Bearbeitet: the cyclist am 16 Nov. 2014
Here's one way. It will shuffle M1 and M2 in place:
% Smaller version of your data
M1 = rand(5,5,3,9);
M2 = rand(9,1);
% Create an random index into your matrices
idx = randperm(9);
% Shuffle both matrices by the same index, preserving the relationship
M1 = M1(:,:,:,idx);
M2 = M2(idx);
Then you can save them.

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by