how to convert character array to cell array
显示 更早的评论
hello, i have a char array of size 1280 * 8 ... values like 11111111 01010101 10100101 ........ 01010101 Now i want as 1*10240 cell array (since 1280 * 8 =10240)...output must be 1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1.....i used str2num ..but they were being conatanated as vertical..i want to conctanate horizantally/..
采纳的回答
num2cell(reshape(X.',1,[]))
13 个评论
and now i want this A cell array having size 1*10240 as 20 * 512... i used reshape(A,[20,512])...but those are conacatanating vertically...
-"but those are conacatanating vertically..."_
I have no idea what that means. The code I gave puts each element of the input char array into one cell. Perhaps you should check the size of the input char array.
i got befor one...thanks for that now am asking new one...i have a cell array "A" of size 1*10240...i want this cell array as 20 * 512 size... i used reshape(A,[20,512])....but that is not correct
"but that is not correct"
I have no idea what that means. Do you mean that your algorithm is incorrect, or that the code is correct but give an unexpected output, or that the code throws an error? If so, what is the complete error message?
I am getting unexpected output.. If cell array is like 1 0 0 1 0 1 0 1 0 0 ...... 1 0 1 (size 1*10240)... now i want output as 1 0 0 1 0 1 0 0....(upto 20 values) next 20 values...so on upto 512 columns....
@Jyothi Alugolu: and what output do you get?
i got output as 20 * 512 only...but values are not correct... values are splitting in vertical order..i want them to split in horizintal way...
@Jyothi Alugolu: I am happy to help you but you need to be much more precise in your description. Please provide a small sample input data and the expected output data. You can upload files by clicking the paperclip button.
Thanks for bearing me... I will explain once again I have a cell array "A" having 0's and 1's of size 1*10240... Now, i want the output cell array of size 20 * 512.. i.e i cell array needs to be spitted with 20 rows and 512 columns since 20 * 512= 10240...i.e first 512 values in 1st row and then next row must start with 513 th cell value...i used reshape command...what i am getting is wrong..what i got is first 20 values are in 1st column and 2nd column starts with 23rd cell value...but what i want is rowwise splitting... i used reshape(A,20,512)...
"...I will explain once again..."
I did not ask for you to explain it again. Please see my last comment.
i have attached 2 files...f1{1,1} cell size is 1*10240...n the output cell f{1,1} is of size 20 * 512.. i want f1 cell array values to split horizontally..i.e 1st 512 values in 1st row and 2nd row must start with 513th value...but what i got in f{1,1} is first 20 values in 1st column and 2nd column starts with 21st value..i want values to split rowwise..not as columnwise...
reshape(C,[512,20]).'
yeah ok..i got it..thank you soo much..
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
标签
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
