Thread Subject: basic data transformation question

Subject: basic data transformation question

From: Migo

Date: 16 Mar, 2010 18:50:26

Message: 1 of 8

Dear all,

I have some question about basic data transformation.
I want to generate a new column by three columns(from data),
and before that, i should exclude some unnecessary data before first trial.

for example:
7.01752 0.0350952 5 5 5
7.01752 -0.056152 5 5 5
7.01904 0.0888062 5 5 5
7.01904 -0.038147 5 5 5
7.01904 0.0344849 0 0 0
7.01904 0.0790405 5 0 0
7.01904 0.015564 5 0 0
7.02057 0.0012207 5 0 0
7.02057 0.0723267 5 0 0
7.01904 0.0344849 0 0 0
7.01904 0.0344849 0 0 0
7.01904 0.0344849 0 0 0
7.01904 0.0344849 0 5 0
7.01904 0.0344849 0 5 0
7.01904 0.0344849 0 5 0
7.01904 0.0344849 0 0 0
7.01904 0.0344849 0 0 0
7.01904 0.0344849 0 0 0
7.01904 0.0344849 0 0 0
7.01904 0.0344849 0 0 5
7.01904 0.0344849 0 0 5
7.01904 0.0344849 0 0 0
7.01904 0.0344849 0 0 0
7.01904 0.0344849 0 0 0

If column(3,4,5) is (5,0,0), and i want to transform 1
If column(3,4,5) is (0,5,0), and i want to transform 2
If column(3,4,5) is (0,0,5), and i want to transform 4
If column(3,4,5) is (0,0,0), and i want to transform 0

and I want to transform these for this result:

exclude(do not display)
exclude(do not display)
exclude(do not display)
exclude(do not display)
7.01904 0.0344849 0
7.01904 0.0790405 1
7.01904 0.015564 1
7.02057 0.0012207 1
7.02057 0.0723267 1
7.01904 0.0344849 0
7.01904 0.0344849 0
7.01904 0.0344849 0
7.01904 0.0344849 2
7.01904 0.0344849 2
7.01904 0.0344849 2
7.01904 0.0344849 0
7.01904 0.0344849 0
7.01904 0.0344849 0
7.01904 0.0344849 0
7.01904 0.0344849 4
7.01904 0.0344849 4
7.01904 0.0344849 0
7.01904 0.0344849 0
7.01904 0.0344849 0

hope I describe my question clear...

Any help is appreciated!(very)
thanks a lot!!

Best,
Migo

Subject: basic data transformation question

From: TideMan

Date: 16 Mar, 2010 19:09:43

Message: 2 of 8

On Mar 17, 7:50 am, "Migo " <migoe...@gmail.com> wrote:
> Dear all,
>
> I have some question about basic data transformation.
> I want to generate a new column by three columns(from data),
> and before that, i should exclude some unnecessary data before first trial.
>
> for example:
> 7.01752 0.0350952       5       5       5
> 7.01752 -0.056152  5    5       5
> 7.01904 0.0888062       5       5       5
> 7.01904 -0.038147       5       5       5
> 7.01904 0.0344849       0       0       0
> 7.01904 0.0790405       5       0       0
> 7.01904 0.015564        5       0       0
> 7.02057 0.0012207       5       0       0
> 7.02057 0.0723267       5       0       0
> 7.01904 0.0344849       0       0       0
> 7.01904 0.0344849       0       0       0
> 7.01904 0.0344849       0       0       0
> 7.01904 0.0344849       0       5       0
> 7.01904 0.0344849       0       5       0
> 7.01904 0.0344849       0       5       0
> 7.01904 0.0344849       0       0       0
> 7.01904 0.0344849       0       0       0
> 7.01904 0.0344849       0       0       0
> 7.01904 0.0344849       0       0       0
> 7.01904 0.0344849       0       0       5
> 7.01904 0.0344849       0       0       5
> 7.01904 0.0344849       0       0       0
> 7.01904 0.0344849       0       0       0
> 7.01904 0.0344849       0       0       0
>
> If column(3,4,5) is (5,0,0), and i want to transform 1
> If column(3,4,5) is (0,5,0), and i want to transform 2
> If column(3,4,5) is (0,0,5), and i want to transform 4
> If column(3,4,5) is (0,0,0), and i want to transform 0
>
> and I want to transform these for this result:
>
> exclude(do not display)
> exclude(do not display)
> exclude(do not display)
> exclude(do not display)
> 7.01904 0.0344849       0
> 7.01904 0.0790405       1
> 7.01904 0.015564        1
> 7.02057 0.0012207       1
> 7.02057 0.0723267       1
> 7.01904 0.0344849       0
> 7.01904 0.0344849       0
> 7.01904 0.0344849       0
> 7.01904 0.0344849       2
> 7.01904 0.0344849       2
> 7.01904 0.0344849       2
> 7.01904 0.0344849 0
> 7.01904 0.0344849       0
> 7.01904 0.0344849       0
> 7.01904 0.0344849       0
> 7.01904 0.0344849       4
> 7.01904 0.0344849       4
> 7.01904 0.0344849       0
> 7.01904 0.0344849       0
> 7.01904 0.0344849       0
>
> hope I describe my question clear...
>
> Any help is appreciated!(very)
> thanks a lot!!
>
> Best,
> Migo

Please post the code that you have tried.

Subject: basic data transformation question

From: Migo

Date: 16 Mar, 2010 19:19:22

Message: 3 of 8

TideMan <mulgor@gmail.com> wrote in message <7f4e50be-9099-4c71-bed9-da7722805dbc@t20g2000yqe.googlegroups.com>...
> On Mar 17, 7:50 am, "Migo " <migoe...@gmail.com> wrote:
> > Dear all,
> >
> > I have some question about basic data transformation.
> > I want to generate a new column by three columns(from data),
> > and before that, i should exclude some unnecessary data before first trial.
> >
> > for example:
> > 7.01752 0.0350952       5       5       5
> > 7.01752 -0.056152  5    5       5
> > 7.01904 0.0888062       5       5       5
> > 7.01904 -0.038147       5       5       5
> > 7.01904 0.0344849       0       0       0
> > 7.01904 0.0790405       5       0       0
> > 7.01904 0.015564        5       0       0
> > 7.02057 0.0012207       5       0       0
> > 7.02057 0.0723267       5       0       0
> > 7.01904 0.0344849       0       0       0
> > 7.01904 0.0344849       0       0       0
> > 7.01904 0.0344849       0       0       0
> > 7.01904 0.0344849       0       5       0
> > 7.01904 0.0344849       0       5       0
> > 7.01904 0.0344849       0       5       0
> > 7.01904 0.0344849       0       0       0
> > 7.01904 0.0344849       0       0       0
> > 7.01904 0.0344849       0       0       0
> > 7.01904 0.0344849       0       0       0
> > 7.01904 0.0344849       0       0       5
> > 7.01904 0.0344849       0       0       5
> > 7.01904 0.0344849       0       0       0
> > 7.01904 0.0344849       0       0       0
> > 7.01904 0.0344849       0       0       0
> >
> > If column(3,4,5) is (5,0,0), and i want to transform 1
> > If column(3,4,5) is (0,5,0), and i want to transform 2
> > If column(3,4,5) is (0,0,5), and i want to transform 4
> > If column(3,4,5) is (0,0,0), and i want to transform 0
> >
> > and I want to transform these for this result:
> >
> > exclude(do not display)
> > exclude(do not display)
> > exclude(do not display)
> > exclude(do not display)
> > 7.01904 0.0344849       0
> > 7.01904 0.0790405       1
> > 7.01904 0.015564        1
> > 7.02057 0.0012207       1
> > 7.02057 0.0723267       1
> > 7.01904 0.0344849       0
> > 7.01904 0.0344849       0
> > 7.01904 0.0344849       0
> > 7.01904 0.0344849       2
> > 7.01904 0.0344849       2
> > 7.01904 0.0344849       2
> > 7.01904 0.0344849 0
> > 7.01904 0.0344849       0
> > 7.01904 0.0344849       0
> > 7.01904 0.0344849       0
> > 7.01904 0.0344849       4
> > 7.01904 0.0344849       4
> > 7.01904 0.0344849       0
> > 7.01904 0.0344849       0
> > 7.01904 0.0344849       0
> >
> > hope I describe my question clear...
> >
> > Any help is appreciated!(very)
> > thanks a lot!!
> >
> > Best,
> > Migo
>
> Please post the code that you have tried.

do you mean my unfinished program?

Subject: basic data transformation question

From: us

Date: 16 Mar, 2010 19:24:23

Message: 4 of 8

"Migo "
> > Please post the code that you have tried.
>
> do you mean my unfinished program?

yes

us

Subject: basic data transformation question

From: Migo

Date: 16 Mar, 2010 19:44:10

Message: 5 of 8

"us " <us@neurol.unizh.ch> wrote in message <hnolt7$6j4$1@fred.mathworks.com>...
> "Migo "
> > > Please post the code that you have tried.
> >
> > do you mean my unfinished program?
>
> yes
>
> us

clear all;
close all;

%name data

GSR = data(i,1);
ECG = data(i,2);
d1 = data(i,3);
d2 = data(i,4);
d3 = data(i,5);

%exclude (before th first trial)

for i = 1:length(data)
end

if d1(i,1)=0 & d2(i,2)=0 & d3(i,3)=0
    GSR2=data(i+1:length(data),1);
    ECG2=data(i+1:length(data),2);
    d12 =data(i+1:length(data),3);
    d22 =data(i+1:length(data),4);
    d32 =data(i+1:length(data),5);
end

%setup a 0 martix

trigger = zeros(i,length(data),1);
    
%categoize trigger

for j = 1:length(data2)
    if d12(j,1)=5 & d22(j,2)=0 & d32(j,3)=0
        data(j,6)=1;
    elseif d12(j,1)=0 & d22(j,2)=5 & d32(j,3)=0
        data(j,6)=2;
    elseif d12(j,1)=0 & d22(j,2)=0 & d32(j,3)=5
        data(j,6)=4;
    elseif d12(j,1)=0 & d22(j,2)=0 & d32(j,3)=0
        data(j,6)=0;
    end
end

%output new list

GSR2 = data2(1);
ECG2 = data2(2);
d12 = data2(3);
d22 = data2(4);
d32 = data2(5);
trigger = data2(6);

Subject: basic data transformation question

From: Migo

Date: 16 Mar, 2010 19:45:21

Message: 6 of 8

"us " <us@neurol.unizh.ch> wrote in message <hnolt7$6j4$1@fred.mathworks.com>...
> "Migo "
> > > Please post the code that you have tried.
> >
> > do you mean my unfinished program?
>
> yes
>
> us

clear all;
close all;

%name data

GSR = data(i,1);
ECG = data(i,2);
d1 = data(i,3);
d2 = data(i,4);
d3 = data(i,5);

%exclude (before th first trial)

for i = 1:length(data)
end

if d1(i,1)=0 & d2(i,2)=0 & d3(i,3)=0
    GSR2=data(i+1:length(data),1);
    ECG2=data(i+1:length(data),2);
    d12 =data(i+1:length(data),3);
    d22 =data(i+1:length(data),4);
    d32 =data(i+1:length(data),5);
end

%setup a 0 martix

trigger = zeros(i,length(data),1);
    
%categoize trigger

for j = 1:length(data2)
    if d12(j,1)=5 & d22(j,2)=0 & d32(j,3)=0
        data(j,6)=1;
    elseif d12(j,1)=0 & d22(j,2)=5 & d32(j,3)=0
        data(j,6)=2;
    elseif d12(j,1)=0 & d22(j,2)=0 & d32(j,3)=5
        data(j,6)=4;
    elseif d12(j,1)=0 & d22(j,2)=0 & d32(j,3)=0
        data(j,6)=0;
    end
end

%output new list

GSR2 = data2(1);
ECG2 = data2(2);
d12 = data2(3);
d22 = data2(4);
d32 = data2(5);
trigger = data2(6);


that all, thanks

Subject: basic data transformation question

From: us

Date: 16 Mar, 2010 20:04:25

Message: 7 of 8

"Migo "
> that all, thanks

well done...

one of the other solutions as a skeleton

% the data
% - input
     b=[
          -1 -1 1 0 0
          -2 -2 0 1 0
          -3 -3 0 0 1
          -4 -4 0 0 0
          -5 -5 1 1 0
          -6 -6 1 1 1
          -7 -7 0 1 1
          -8 -8 1 0 0
          -9 -9 0 0 0
     ];
% - template
     bt=[
          1 0 0 1
          0 1 0 2
          0 0 1 3
          0 0 0 4 % <- zero marker
     ];
% the engine
     [ix,ix]=ismember(b(:,3:5),bt(:,1:3),'rows');
     r=[b(:,1:2),ix];
     r(r(:,end)==0,:)=[];
     r(r(:,end)==4,end)=0;
% the result
     disp(r);
%{
     -1 -1 1
     -2 -2 2
     -3 -3 3
     -4 -4 4
     -8 -8 1
%}

us

Subject: basic data transformation question

From: us

Date: 16 Mar, 2010 20:31:29

Message: 8 of 8

"us "
> disp(r);
> %{
> -1 -1 1
> -2 -2 2
> -3 -3 3
> -4 -4 4
> -8 -8 1
> %}

stupid typo(!)...

     disp(r);
%{
     -1 -1 1
     -2 -2 2
     -3 -3 3
     -4 -4 0 % <- zero marker...
     -8 -8 1
     -9 -9 0 % <- zero marker...
%}

sorry for confusion...
us

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
ismember us 16 Mar, 2010 16:04:34
logical indexing us 16 Mar, 2010 16:04:34
code us 16 Mar, 2010 16:04:34
data transforma... Migo 16 Mar, 2010 14:54:07
data analysis Migo 16 Mar, 2010 14:54:07
rssFeed for this Thread

Contact us at files@mathworks.com