separating matrices and performing operation
1 view (last 30 days)
Show older comments
I have a code
A is a matrix
n = numel(A);
A1_30 = repmat(A,[1,1,30]);
t = ones(size(A));
for j1 = 1:size(A1_30,3)
p = t;
p(randi(n,15000,1)) = 0;
A1_30(:,:,j1) = A1_30(:,:,j1).*p;
end
A1_30 has 30 matrices,now for first 10 matrices ,i want to do some operation,next 10 another operation and last 10 anoher operation,please tell how to process these in a for loop
[Merged information from duplicate question]
I have a code
A=rand(256,256)
n = numel(A);
A1_30 = repmat(A,[1,1,30]);
t = ones(size(A));
for j1 = 1:size(A1_30,3)
p = t;
p(randi(n,15000,1)) = 0;
A1_30(:,:,j1) = A1_30(:,:,j1).*p;
end
no i want to separate these matrices int 3 parts,into 10 each for performing different operation
i need first 10 matrices in separate loop ,second in another for loop ,another 10 in another for loop,
please help
for example
for the 10 imatrix i want to convert them into bw,
for next 10;i want to resize to 128x128;PLEASE HELP,FOR next 10 another operation,please say for one operation
3 Comments
Walter Roberson
on 24 May 2012
Removing any information in your (now merged) question that is no longer relevant would help make the question easier to understand.
People answer when they feel like answering. There are no promises of answers here. It is just after midnight in most of North America, so the North Americans are mostly in bed (which is where I will be in a few short minutes.) It is roughly 6:30 in the morning in western Europe, so the volunteers there are mostly still sleeping. You can pretty much expect another 2 to 3 hours before any of the other regular volunteers reads your question; whether they will respond at all is up to them.
If you need a response more quickly than "Sometime after morning coffee, or a few days after that perhaps", then it is recommended that you hire a consultant.
And now it is time for me to rest my aching fingers.
Answers (1)
the cyclist
on 23 May 2012
One possible way:
A1_30 = rand(5,5,30);
for nk = 1:3
indexToThisThird = 10*(nk-1) + (1:10);
A1_30(:,:,indexToThisThird) = nk; % Replace this line with whatever you want to do
end
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!