Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
separate data

Subject: separate data

From: wahyoe Unggul

Date: 8 May, 2011 07:16:04

Message: 1 of 5

is you have ideas, I try to import a data and then data.

previous data
2 2 2 0 1
2 2 2 0 0

2 3 4 5
2 1 6 7
3 5 6 8

1 2 3
15 6 17

[data,directory]=uigetfile({'.txt'})
f2r=fullfile(directory,data)
data=(importdata(f2r))

result
data =
tes.txt
directory =
C:\Documents and Settings\wahyoe\My Documents\
f2r =
C:\Documents and Settings\wahyoe\My Documents\tes.txt
data =

     2 2 7
     2 2 8
     2 3 4
     5 NaN NaN
     2 1 6
     7 NaN NaN
     3 5 6
     8 NaN NaN
     1 2 3
    15 6 17

is the above results it can be separated as below
A=2 2 2 0 1
    2 2 2 0 0

B=2 3 4 5
   2 1 6 7
   3 5 6 8

    1 2 3
   15 6 17

thanks
wahyoe

Subject: separate data

From: wahyoe Unggul

Date: 8 May, 2011 08:00:21

Message: 2 of 5

sorry
is you have ideas, I try to import a data and then data.

previous data

2 2 2 0 1
2 2 2 0 0

2 3 4 5
2 1 6 7
3 5 6 8

1 2 3
15 6 17

3 8 6
14 2 3
14 2 3

18 6 3 3 4 5 9
1 6 7 8 6 1 2

result

data =

tes.txt


directory =

C:\Documents and Settings\wahyoe\My Documents\


f2r =

C:\Documents and Settings\wahyoe\My Documents\tes.txt


gxj =

     2 2 2 0 1
     2 2 2 0 0
     2 3 4 5 NaN
     2 1 6 7 NaN
     3 5 6 8 NaN
     1 2 3 NaN NaN
    15 6 17 NaN NaN
     3 8 6 NaN NaN
    14 2 3 NaN NaN
    14 2 3 NaN NaN
    18 6 3 3 4
     5 9 NaN NaN NaN
     1 6 7 8 6
     1 2 NaN NaN NaN

is the above results it can be separated as below

A=2 2 2 0 1
  2 2 2 0 0

B=2 3 4 5
  2 1 6 7
  3 5 6 8

C=1 2 3
  15 6 17

D= 3 8 6
  14 2 3
  14 2 3

E=18 6 3 3 4 5 9
  1 6 7 8 6 1 2

Subject: separate data

From: Nasser M. Abbasi

Date: 8 May, 2011 09:08:15

Message: 3 of 5

On 5/8/2011 1:00 AM, wahyoe Unggul wrote:
> sorry
> is you have ideas, I try to import a data and then data.
>
> previous data
>
> 2 2 2 0 1
> 2 2 2 0 0
>
> 2 3 4 5
> 2 1 6 7
> 3 5 6 8
>
> 1 2 3
> 15 6 17
>
> 3 8 6
> 14 2 3
> 14 2 3
>
> 18 6 3 3 4 5 9
> 1 6 7 8 6 1 2
>
> result
>
> data =
>
> tes.txt
>
>
> directory =
>
> C:\Documents and Settings\wahyoe\My Documents\
>
>
> f2r =
>
> C:\Documents and Settings\wahyoe\My Documents\tes.txt
>
>
> gxj =
>
> 2 2 2 0 1
> 2 2 2 0 0
> 2 3 4 5 NaN
> 2 1 6 7 NaN
> 3 5 6 8 NaN
> 1 2 3 NaN NaN
> 15 6 17 NaN NaN
> 3 8 6 NaN NaN
> 14 2 3 NaN NaN
> 14 2 3 NaN NaN
> 18 6 3 3 4
> 5 9 NaN NaN NaN
> 1 6 7 8 6
> 1 2 NaN NaN NaN
>
> is the above results it can be separated as below
>
> A=2 2 2 0 1
> 2 2 2 0 0
>
> B=2 3 4 5
> 2 1 6 7
> 3 5 6 8
>
> C=1 2 3
> 15 6 17
>
> D= 3 8 6
> 14 2 3
> 14 2 3
>
> E=18 6 3 3 4 5 9
> 1 6 7 8 6 1 2


may be:

A=[2 2 2 0 1;
      2 2 2 0 0;
      2 3 4 5 NaN;
      2 1 6 7 NaN;
      3 5 6 8 NaN;
      1 2 3 NaN NaN;
     15 6 17 NaN NaN;
      3 8 6 NaN NaN;
     14 2 3 NaN NaN;
     14 2 3 NaN NaN;
     18 6 3 3 4;
      5 9 NaN NaN NaN;
      1 6 7 8 6;
      1 2 NaN NaN NaN];

-------------------------------------------
  R=arrayfun(@(i) A(i,not(isnan(A(i,:)))),1:size(A,1),'UniformOutput',false)
  [v,I]=sort(cellfun(@(x) size(x,2), R));
  [a,b,c,d,e,f,g,h,l,m,n,k,z,y]=deal(R{I})
-------------------------------------------------

EDU>> R{I}

      5 9
      1 2
      1 2 3
     15 6 17
      3 8 6
     14 2 3
     14 2 3
      2 3 4 5
      2 1 6 7
      3 5 6 8
      2 2 2 0 1
      2 2 2 0 0
     18 6 3 3 4
      1 6 7 8 6

a =
      5 9
b =
      1 2
c =
      1 2 3
d =
     15 6 17
e =
      3 8 6
f =
     14 2 3
g =
     14 2 3
h =
      2 3 4 5
l =
      2 1 6 7
m =
      3 5 6 8
n =
      2 2 2 0 1
k =
      2 2 2 0 0
z =
     18 6 3 3 4
y =
      1 6 7 8 6

You can now do whatever you want with your variables above.

--Nasser

Subject: separate data

From: wahyoe Unggul

Date: 8 May, 2011 11:49:05

Message: 4 of 5

nasser
what if any data to be imported only limited by space, for example:
data.txt
2 3 5 7 8
2 5 12 3 6

2 8 3
1 7 9
1 2 3

1 2 5 6 8 6 7
5 6 8 4 5 6 9

after the import data is to be like this
A=2 3 5 7 8
2 5 12 3 6

B=2 8 3
1 7 9
1 2 3

C=1 2 5 6 8 6 7
5 6 8 4 5 6 9

Subject: separate data

From: wahyoe Unggul

Date: 8 May, 2011 11:55:04

Message: 5 of 5

nasser
what if any data to be imported only limited by space, for example:
data.txt
2 3 5 7 8
2 5 12 3 6

2 8 3
1 7 9
1 2 3

1 2 5 6 8 6 7
5 6 8 4 5 6 9

after the import data is to be like this
A=2 3 5 7 8
2 5 12 3 6

B=2 8 3
1 7 9
1 2 3

C=1 2 5 6 8 6 7
5 6 8 4 5 6 9

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us