1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Filtering with Matlab

  1. Nov 9, 2009 #1


    User Avatar

    1. The problem statement, all variables and given/known data

    I have got a table of data, and want to use Matlab to sort this data and filter out some variables. The data was orginally in a FITS format.

    2. Relevant equations


    3. The attempt at a solution

    Sorry if this is the wrong thread.

    I have tried two different versions of code:

    hd = (data{12} < rsd);
    data_filtered = filter(hd,data,:);


    idx = (rs < rsd);
    data_filtered = data(:,idx);

    I need it to filter out all data with a Redshift less then a specified number

    Any ideas or thoughts would be really appreciated


  2. jcsd
  3. Nov 11, 2009 #2


    User Avatar

    Okay, I have found that the data seems to be in a 1x55 table which is the reason I am having trouble filtering it - I get a error message about matrix dimensions.

    Any ideas the best way to sort this kind of table?

    Many thanks,

  4. Nov 13, 2009 #3


    User Avatar

    Okay I was told Matlab had put my Data in a wierd way so I have now entered the data into a Structure. Does the Filter command still work for Structures, as using the code:

    idx = (datastruct.Redshift < rsd);
    data_filtered = datastruct(idx)

    Gives me a Matrix Error:

    ??? Index exceeds matrix dimensions.

    Error in ==> DensityFunct3 at 12
    data_filtered = datastruct(idx)

    Any ideas would be greatly appreciated

    Many Thanks

  5. Dec 22, 2009 #4
    I think the problem is in the index of datastruct, as it is showing. May be the length of data_filtered is not the same as datastruct. It is very common problem occurs in MATLAB. For Example : if H=[1:5]; and then Y=[1:7]; and if you do H=Y(15); then it occurs. Hope it is helpful
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook