To split class in a cell array

3 views (last 30 days)
Hi,
I am having cell array (A) of 3072*30 cells. I need to mention in my code that first 15 columns (1 to 15) belongs to class_1 and rest of the 15 columns (16 to 30) belongs to class_2. How can I do this? Kindly help me with this. Thanks in advance.
  2 Comments
Shalmiya Paulraj SOC
Shalmiya Paulraj SOC on 20 Jul 2022
I need to classify them as variables.

Sign in to comment.

Accepted Answer

Dyuman Joshi
Dyuman Joshi on 20 Jul 2022
Looks like a simple variable assignment
%random data
y=num2cell(rand(10,30))
y = 10×30 cell array
{[0.0429]} {[0.6573]} {[0.4491]} {[0.8743]} {[0.8910]} {[0.6037]} {[0.4992]} {[0.3161]} {[0.5085]} {[0.8149]} {[0.4411]} {[0.9675]} {[0.9415]} {[0.5472]} {[0.2184]} {[0.0718]} {[0.4556]} {[0.8457]} {[0.3144]} {[0.1920]} {[0.0047]} {[0.3226]} {[0.9917]} {[0.9409]} {[0.0397]} {[0.8016]} {[0.3305]} {[0.8369]} {[0.1377]} {[0.2737]} {[0.2022]} {[0.4322]} {[0.9603]} {[0.1885]} {[0.7555]} {[0.2301]} {[0.3248]} {[0.3585]} {[0.1594]} {[0.2277]} {[0.0316]} {[0.4856]} {[0.7924]} {[0.3109]} {[0.1601]} {[0.6248]} {[0.8429]} {[0.9777]} {[0.6154]} {[0.9903]} {[0.1442]} {[0.6801]} {[0.5512]} {[0.1111]} {[0.1293]} {[0.6780]} {[0.3227]} {[0.7576]} {[0.9418]} {[0.3936]} {[0.6480]} {[0.1052]} {[0.7991]} {[0.3137]} {[0.2548]} {[0.5887]} {[0.8145]} {[0.9278]} {[0.3293]} {[0.0333]} {[0.9802]} {[0.2802]} {[0.1858]} {[0.4807]} {[0.8810]} {[0.5598]} {[0.7994]} {[0.8112]} {[0.1728]} {[0.4948]} {[0.8629]} {[0.8291]} {[0.2189]} {[0.3770]} {[0.4297]} {[0.2367]} {[0.6692]} {[0.1430]} {[0.9057]} {[0.0910]} {[0.9861]} {[0.6404]} {[0.0969]} {[0.6612]} {[0.8557]} {[0.9868]} {[0.3536]} {[0.1109]} {[0.0372]} {[0.8165]} {[0.6213]} {[0.5194]} {[0.8011]} {[0.9668]} {[0.7000]} {[0.4871]} {[0.2498]} {[0.8631]} {[0.3664]} {[0.8057]} {[0.0339]} {[0.5204]} {[0.8456]} {[0.4612]} {[0.9991]} {[0.2468]} {[0.2655]} {[0.2095]} {[0.4647]} {[0.8753]} {[0.5260]} {[0.8953]} {[0.6656]} {[0.6436]} {[0.4224]} {[0.7272]} {[0.5952]} {[0.4938]} {[0.9162]} {[0.7548]} {[0.0474]} {[0.3580]} {[0.1411]} {[0.6557]} {[0.5780]} {[0.5417]} {[0.1439]} {[0.1115]} {[0.9631]} {[0.3361]} {[0.7031]} {[0.2404]} {[0.9601]} {[0.9841]} {[0.1836]} {[0.0819]} {[0.2653]} {[0.4867]} {[0.2826]} {[0.9345]} {[0.6508]} {[0.3016]} {[0.4134]} {[0.7558]} {[0.8422]} {[0.7709]} {[0.9673]} {[0.0363]} {[0.1084]} {[0.3923]} {[0.5217]} {[0.4439]} {[0.3219]} {[0.5695]} {[0.1429]} {[0.6350]} {[0.5820]} {[0.6552]} {[0.9112]} {[0.8541]} {[0.7789]} {[0.2666]} {[0.1783]} {[0.8171]} {[0.3276]} {[0.9600]} {[0.8336]} {[0.2152]} {[0.9361]} {[0.1189]} {[0.5196]} {[0.6815]} {[0.1660]} {[0.3689]} {[0.1190]} {[0.6952]} {[0.9645]} {[0.9824]} {[0.1223]} {[0.2963]} {[0.2798]} {[0.8806]} {[0.6004]} {[0.3141]} {[0.5818]} {[0.5378]} {[0.2794]} {[0.1674]} {[0.5274]} {[0.5888]} {[0.9491]} {[0.7921]} {[0.3445]} {[0.5471]} {[0.3866]} {[0.8285]} {[0.6762]} {[0.1552]} {[0.1990]} {[0.3763]} {[0.3030]} {[0.7435]} {[0.2165]} {[0.0967]} {[0.7550]} {[0.2750]} {[0.8788]} {[0.9565]} {[0.6438]} {[0.8846]} {[0.5238]} {[0.4508]} {[0.6687]} {[0.8660]} {[0.1495]} {[0.8615]} {[0.9213]} {[0.9919]} {[0.6902]} {[0.5372]} {[0.0036]} {[0.5433]} {[0.4141]} {[0.1074]} {[0.8653]} {[0.2755]} {[0.7174]} {[0.9411]} {[0.6437]} {[0.8933]} {[0.3792]} {[0.0201]} {[0.8181]} {[0.1260]} {[0.6229]} {[0.0427]} {[0.2552]} {[0.8650]} {[0.7686]} {[0.4479]} {[0.2435]} {[0.1535]} {[0.0433]} {[0.7223]} {[0.1383]} {[0.7527]} {[0.0435]} {[0.4947]} {[0.0367]} {[0.4833]} {[0.1654]} {[0.0025]} {[0.0632]} {[0.3833]} {[0.9368]} {[0.0685]} {[0.8810]} {[0.2998]} {[0.6078]} {[0.2701]} {[0.2163]} {[0.1600]} {[0.3561]} {[0.5374]} {[0.5097]} {[0.9155]} {[0.2198]} {[0.3409]} {[0.8855]} {[0.6301]} {[0.5137]} {[0.3076]} {[0.9558]} {[0.4299]} {[0.5303]} {[0.6680]} {[0.8918]} {[0.5571]} {[0.7782]} {[0.2087]} {[0.8924]} {[0.0161]} {[0.6197]} {[0.9198]} {[0.7194]} {[0.2045]} {[0.0928]} {[0.0480]} {[0.7515]} {[0.0187]}
class_1 = y(:,1:15)
class_1 = 10×15 cell array
{[0.0429]} {[0.6573]} {[0.4491]} {[0.8743]} {[0.8910]} {[0.6037]} {[0.4992]} {[0.3161]} {[0.5085]} {[0.8149]} {[0.4411]} {[0.9675]} {[0.9415]} {[0.5472]} {[0.2184]} {[0.2022]} {[0.4322]} {[0.9603]} {[0.1885]} {[0.7555]} {[0.2301]} {[0.3248]} {[0.3585]} {[0.1594]} {[0.2277]} {[0.0316]} {[0.4856]} {[0.7924]} {[0.3109]} {[0.1601]} {[0.6480]} {[0.1052]} {[0.7991]} {[0.3137]} {[0.2548]} {[0.5887]} {[0.8145]} {[0.9278]} {[0.3293]} {[0.0333]} {[0.9802]} {[0.2802]} {[0.1858]} {[0.4807]} {[0.8810]} {[0.9861]} {[0.6404]} {[0.0969]} {[0.6612]} {[0.8557]} {[0.9868]} {[0.3536]} {[0.1109]} {[0.0372]} {[0.8165]} {[0.6213]} {[0.5194]} {[0.8011]} {[0.9668]} {[0.7000]} {[0.5260]} {[0.8953]} {[0.6656]} {[0.6436]} {[0.4224]} {[0.7272]} {[0.5952]} {[0.4938]} {[0.9162]} {[0.7548]} {[0.0474]} {[0.3580]} {[0.1411]} {[0.6557]} {[0.5780]} {[0.6508]} {[0.3016]} {[0.4134]} {[0.7558]} {[0.8422]} {[0.7709]} {[0.9673]} {[0.0363]} {[0.1084]} {[0.3923]} {[0.5217]} {[0.4439]} {[0.3219]} {[0.5695]} {[0.1429]} {[0.5196]} {[0.6815]} {[0.1660]} {[0.3689]} {[0.1190]} {[0.6952]} {[0.9645]} {[0.9824]} {[0.1223]} {[0.2963]} {[0.2798]} {[0.8806]} {[0.6004]} {[0.3141]} {[0.5818]} {[0.3030]} {[0.7435]} {[0.2165]} {[0.0967]} {[0.7550]} {[0.2750]} {[0.8788]} {[0.9565]} {[0.6438]} {[0.8846]} {[0.5238]} {[0.4508]} {[0.6687]} {[0.8660]} {[0.1495]} {[0.3792]} {[0.0201]} {[0.8181]} {[0.1260]} {[0.6229]} {[0.0427]} {[0.2552]} {[0.8650]} {[0.7686]} {[0.4479]} {[0.2435]} {[0.1535]} {[0.0433]} {[0.7223]} {[0.1383]} {[0.2163]} {[0.1600]} {[0.3561]} {[0.5374]} {[0.5097]} {[0.9155]} {[0.2198]} {[0.3409]} {[0.8855]} {[0.6301]} {[0.5137]} {[0.3076]} {[0.9558]} {[0.4299]} {[0.5303]}
class_2 = y(:,16:30)
class_2 = 10×15 cell array
{[0.0718]} {[0.4556]} {[0.8457]} {[0.3144]} {[0.1920]} {[0.0047]} {[0.3226]} {[0.9917]} {[0.9409]} {[0.0397]} {[0.8016]} {[0.3305]} {[0.8369]} {[0.1377]} {[0.2737]} {[0.6248]} {[0.8429]} {[0.9777]} {[0.6154]} {[0.9903]} {[0.1442]} {[0.6801]} {[0.5512]} {[0.1111]} {[0.1293]} {[0.6780]} {[0.3227]} {[0.7576]} {[0.9418]} {[0.3936]} {[0.5598]} {[0.7994]} {[0.8112]} {[0.1728]} {[0.4948]} {[0.8629]} {[0.8291]} {[0.2189]} {[0.3770]} {[0.4297]} {[0.2367]} {[0.6692]} {[0.1430]} {[0.9057]} {[0.0910]} {[0.4871]} {[0.2498]} {[0.8631]} {[0.3664]} {[0.8057]} {[0.0339]} {[0.5204]} {[0.8456]} {[0.4612]} {[0.9991]} {[0.2468]} {[0.2655]} {[0.2095]} {[0.4647]} {[0.8753]} {[0.5417]} {[0.1439]} {[0.1115]} {[0.9631]} {[0.3361]} {[0.7031]} {[0.2404]} {[0.9601]} {[0.9841]} {[0.1836]} {[0.0819]} {[0.2653]} {[0.4867]} {[0.2826]} {[0.9345]} {[0.6350]} {[0.5820]} {[0.6552]} {[0.9112]} {[0.8541]} {[0.7789]} {[0.2666]} {[0.1783]} {[0.8171]} {[0.3276]} {[0.9600]} {[0.8336]} {[0.2152]} {[0.9361]} {[0.1189]} {[0.5378]} {[0.2794]} {[0.1674]} {[0.5274]} {[0.5888]} {[0.9491]} {[0.7921]} {[0.3445]} {[0.5471]} {[0.3866]} {[0.8285]} {[0.6762]} {[0.1552]} {[0.1990]} {[0.3763]} {[0.8615]} {[0.9213]} {[0.9919]} {[0.6902]} {[0.5372]} {[0.0036]} {[0.5433]} {[0.4141]} {[0.1074]} {[0.8653]} {[0.2755]} {[0.7174]} {[0.9411]} {[0.6437]} {[0.8933]} {[0.7527]} {[0.0435]} {[0.4947]} {[0.0367]} {[0.4833]} {[0.1654]} {[0.0025]} {[0.0632]} {[0.3833]} {[0.9368]} {[0.0685]} {[0.8810]} {[0.2998]} {[0.6078]} {[0.2701]} {[0.6680]} {[0.8918]} {[0.5571]} {[0.7782]} {[0.2087]} {[0.8924]} {[0.0161]} {[0.6197]} {[0.9198]} {[0.7194]} {[0.2045]} {[0.0928]} {[0.0480]} {[0.7515]} {[0.0187]}
%if you need matrix instead cell
class_1 = cell2mat(y(:,1:15))
class_1 = 10×15
0.0429 0.6573 0.4491 0.8743 0.8910 0.6037 0.4992 0.3161 0.5085 0.8149 0.4411 0.9675 0.9415 0.5472 0.2184 0.2022 0.4322 0.9603 0.1885 0.7555 0.2301 0.3248 0.3585 0.1594 0.2277 0.0316 0.4856 0.7924 0.3109 0.1601 0.6480 0.1052 0.7991 0.3137 0.2548 0.5887 0.8145 0.9278 0.3293 0.0333 0.9802 0.2802 0.1858 0.4807 0.8810 0.9861 0.6404 0.0969 0.6612 0.8557 0.9868 0.3536 0.1109 0.0372 0.8165 0.6213 0.5194 0.8011 0.9668 0.7000 0.5260 0.8953 0.6656 0.6436 0.4224 0.7272 0.5952 0.4938 0.9162 0.7548 0.0474 0.3580 0.1411 0.6557 0.5780 0.6508 0.3016 0.4134 0.7558 0.8422 0.7709 0.9673 0.0363 0.1084 0.3923 0.5217 0.4439 0.3219 0.5695 0.1429 0.5196 0.6815 0.1660 0.3689 0.1190 0.6952 0.9645 0.9824 0.1223 0.2963 0.2798 0.8806 0.6004 0.3141 0.5818 0.3030 0.7435 0.2165 0.0967 0.7550 0.2750 0.8788 0.9565 0.6438 0.8846 0.5238 0.4508 0.6687 0.8660 0.1495 0.3792 0.0201 0.8181 0.1260 0.6229 0.0427 0.2552 0.8650 0.7686 0.4479 0.2435 0.1535 0.0433 0.7223 0.1383 0.2163 0.1600 0.3561 0.5374 0.5097 0.9155 0.2198 0.3409 0.8855 0.6301 0.5137 0.3076 0.9558 0.4299 0.5303

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by