separating matrices and performing operation

1 次查看(过去 30 天)
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 个评论
kash
kash 2012-5-24
Walter what infromation must be edited in order to get the answere
Walter Roberson
Walter Roberson 2012-5-24
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.

请先登录,再进行评论。

回答(1 个)

the cyclist
the cyclist 2012-5-23
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
  1 个评论
kash
kash 2012-5-24
I could not understand these codings
I have an matrice of A1_30 = rand(256,256,30);
from A1_30(:,:,1) to A1_30(:,:,10);i will have 10 matrices say images,for these 10 images i want to convert them into bw,
for next 10;i want to RESIZE THE IMAGE TI 128x128;PLEASE HELP,FOR next 10 another operation,please say for one operation

请先登录,再进行评论。

类别

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

标签

Community Treasure Hunt

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

Start Hunting!

Translated by