how to convert cell to mat
Ältere Kommentare anzeigen
I have a cell array of size h=4X1. Inside it has 4 different matrices of size 32X64. How to convert it to matrix. I used htemp=cell2mat(h). Now the size is 128x64. After that i try to separate the real and imaginary parts of htemp using htempreal=zeros(128,64,2). then htempreal(:,:,1)=real(htemp) and htempreal(:,:,2)=imag(htemp). at this point it shows error unable to perform assignment because the size of the left side is 128 by 64 and the size of the right side is 32 by 64.
Antworten (1)
KSSV
am 28 Mär. 2023
4 Kommentare
ANUSAYA SWAIN
am 28 Mär. 2023
KSSV
am 28 Mär. 2023
Check the size of htemp it is 32x64. You cannot store it in LHS of size 128x64. Check you data h, which is a cell. Try:
htemp = cell2mat(reshape(h,2,2)) ;
htempreal=zeros(128,64,2) ;
htempreal(:,:,1)=real(htemp);
htempreal(:,:,2)=imag(htemp);
OR
htemp = cell2mat(h) ;
[m,n] = size(htemp) ;
htempreal = zeros(m,n,2) ;
htempreal(:,:,1)=real(htemp);
htempreal(:,:,2)=imag(htemp);
ANUSAYA SWAIN
am 28 Mär. 2023
KSSV
am 28 Mär. 2023
May be you are overwrititng the variable.......we can only help on looking into your full code.
Kategorien
Mehr zu Data Type Conversion finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!