matrix to cell convert?

3 次查看(过去 30 天)
SRI
SRI 2019-8-29
评论: Rik 2019-9-3
i have A=4*16384 double matrix and converted into 64*64 cell and each cell have again 4*4 double matrix ,now iam trying this below code
c = mat2cell(A,4,4*ones(64,64))
but it gives error
Error using mat2cell
Input arguments, D1 through D2, should be vectors.
  4 个评论
SRI
SRI 2019-8-29
编辑:SRI 2019-8-29
sir actually before i have S=64*64 cell and each cell has 4*4 double,and i changed to matrix by using
A= [S{:}]; % i got dimensions like 4*16384 double
and i want changed A into S with dimensions 64*64 cell
Rik
Rik 2019-9-3
Comment sent by email:
i have rgb image and now i converted into 64*64 cell and each cell block has 8*8*3 cell blocks but i want to apply iwt to each and every individual blocks and apply reverse process and i want retrieve original cell has 64*64 cell blocks...please give the solution sir...............
Which part is your actual question? Do you want to know how to apply a function to all elements of a cell array? Do you want to know how to redivide a cell array containing matrices?

请先登录,再进行评论。

采纳的回答

Rik
Rik 2019-8-29
I'm going to assume you have 256x256 separated into 64x64 blocks and you want to redistribute to 4x4 blocks.
%create some data
data=reshape(1:(64*4)^2,64*4,64*4);
data=mat2cell(data,64*ones(1,4),64*ones(1,4));
A=cell2mat(data);%convert to a 256x26 matrix
B=mat2cell(A,4*ones(1,64),4*ones(1,64));%divide into 4x4 blocks
  1 个评论
SRI
SRI 2019-8-29
wow,Great sir....
U are a great person thanks for helping me.I understand everything in a short time period.

请先登录,再进行评论。

更多回答(1 个)

Bruno Luong
Bruno Luong 2019-8-29
编辑:Bruno Luong 2019-8-29
Depending on what you want as organization, either
C = mat2cell(reshape(A,4*64,4*64),4*ones(1,64),4*ones(1,64))
or
C = reshape(mat2cell(A,4,4*ones(1,64*64)),64,64) % EDIT: This is the reverse of A = [C{:}]
or ....
  7 个评论
Bruno Luong
Bruno Luong 2019-8-29
编辑:Bruno Luong 2019-8-29
Why? You got your answer here, why should I post there (where the order is not specified)?
SRI
SRI 2019-8-29
i want to accept both ur answers,beacuse you done great favout to me

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

产品


版本

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by