tough matlab problem help plz!

edited August 2008 in Science & Tech
Hi everyone i am new here and i'd really appreciate it if someone could assist me with a matlab problem i have. Here goes:
I have an 100*176 array with each column containing data both categorical and numerical (a column can contain only one type of data though). What i need is a script to separate this array into every possible combination of arrays of 100*2 and 100*3 and for each of these smaller arrays to use their collumns as values in an anovan model (up to 3 way interactions, and sstype=3). To use matlab help as an example the anovan model will look something like this
anovan(MPG,{org cyl4 when},3,3,varnames)
where 'org' 'cyl4' and 'when' are the values derived from the collumns of one of the 100*3 smaller arrays and MPG is an 100*1 array that i have created beforehand and will be the same for all the combinations of values. I know the description of my problem isn't that clear but it's the best way i can describe it so if you have any questions about it please tell me so i can clear things up. Also if you could tell me how to write a script just to separate the bigger array into every possible combination of arrays of 100*2 and 100*3 that would be great help too!

Comments

  • shwaipshwaip bluffin' with my muffin Icrontian
    edited August 2008
    this assumes your data is in a matrix called data
    for ii=1:176
     for jj=(ii+1):176
      ind = [ii jj];
      anovan(MPG,data(:,ind),{whatever else goes here}); %this does 2d anova
      for kk=(jj+1):176
       ind = [ii jj kk];
       anovan(MPG,data(:,ind),{whatever else goes here}); %this does 3d anova
      end
     end
    end
    
  • edited August 2008
    i am not really sure but doesn't that take only succesive collumns from the "data" matrix? e.g. ii=1 -->jj=2, ii=2 --> jj=3 etc? i need every possible combination between the collumns to work with. thanks a lot for your help though.. even so i have something to start working on... if you think something more please let me know.
    thanks again!
  • shwaipshwaip bluffin' with my muffin Icrontian
    edited August 2008
    it tests all combinations.
  • edited August 2008
    i checked it out and you are right it's all the combinations. hehe i'm still very new at this. the anovan part has some problems but i think i can manage that on my own. (the values inserted in the anovan must be in the form of 176*1 char array). thanks a lot again! you've really been a great help!


    *EDIT

    I ended up with two scripts one for a matrix that has collumns containing only categorical data and one for collumns containing only numerical. Can you help me write a script that can work with a matrix having collumns of both kinds? I was wandering if it can be done with an if-else-end construction or if i have to use input() command giving information about which collumn is numerical.

    thank you.

    categorical data

    for i=1:176 ><O:p></O:p>
    for j=(i+1):176<O:p></O:p>
    big=a(:,i);<O:p></O:p>
    big=char(big);<O:p></O:p>
    mak=a(:,j);<O:p></O:p>
    mak=char(mak);<O:p></O:p>
    anovan(total_adds,{big mak},'model','full','sstype',3)<O:p></O:p>
    for k=(j+1):176<O:p></O:p>
    lad=a(:,k)<O:p></O:p>
    lad=char(lad)<O:p></O:p>
    anovan(total_adds,{big mak lad},'model','full','sstype',3)<O:p></O:p>
    end<O:p></O:p>
    end<O:p></O:p>





    numerical data


    for i=1:176<O:p></O:p>
    for j=(i+1):176<O:p></O:p>
    big=a(:,i);<O:p></O:p>
    big=cell2mat(big);<O:p></O:p>
    mak=a(:,j);<O:p></O:p>
    mak=cell2mat(mak);<O:p></O:p>
    anovan(total_adds,{big mak},'continuous',[1 1],'model','full','sstype',3)<O:p></O:p>
    for k=(j+1):176<O:p></O:p>
    lad=a(:,k)<O:p></O:p>
    lad=cell2mat(lad)<O:p></O:p>
    anovan(total_adds,{big mak lad},'continuous',[1 1 1],'model','full','sstype',3)<O:p></O:p>
    end<O:p></O:p>
    end
Sign In or Register to comment.