Converting a cell type data to a 4d format
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Saugata Bose
il 25 Giu 2019
Modificato: Saugata Bose
il 26 Giu 2019
Hi,
I struck into a phase where my data came into one format and I need to reshape it to other format. I have tried reshape and permute, yet, I did not achieve the ultimate result. Would you please help me to get the result. And I would really appreciate if you would please explain your solution.
Input:
A={5 x 1} cell type data where every cell is in this format {300 x 18 single}
Expected Output:
I expect to have an output where each element of A will be formatted as 18 x 300 x 1 x 1 structure.
I have tried to implement the following code to format A but I did not achieve the expected result.
z = cellfun(@(X) permute(X,[3 2 1]),A,'UniformOutput',false);
I am looking for your advice in this regard.
Thanks
3 Commenti
Risposta accettata
madhan ravi
il 26 Giu 2019
Try this:
AA=cellfun(@(x) x.',A,'un',0);
Wanted = cat(4,AA{:})
3 Commenti
madhan ravi
il 26 Giu 2019
Modificato: madhan ravi
il 26 Giu 2019
Bose keep the facts straight the latter comment you made seems to contradict the original question before you edited.
:1 is not a valid MATLAB syntax
Più risposte (1)
KSSV
il 26 Giu 2019
% CReate random input for demo
A = cell(5,1) ;
for i = 1:5
A{i} = rand(300,18) ;
end
B = zeros(18,300,5) ;
for i = 1:5
B(:,:,i) = A{i}' ;
end
0 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!