Filtering Data with Matlab in FITS Format

  • Thread starter TFM
  • Start date
  • Tags
    Matlab
In summary, the user is trying to use Matlab to sort and filter data from a table in FITS format. They have tried two different versions of code, but are encountering errors with matrix dimensions. They then try to enter the data into a structure, but encounter a similar error. They believe the problem may be with the index of the data and ask for help in solving the issue.
  • #1
TFM
1,026
0

Homework Statement



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.

Homework Equations



N/A

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,:);

and

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

Thanks,

TFM
 
Physics news on Phys.org
  • #2
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,

TFM
 
  • #3
Okay I was told Matlab had put my Data in a weird 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

TFM
 
  • #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
 

FAQ: Filtering Data with Matlab in FITS Format

How can I filter data in Matlab using FITS format?

To filter data in Matlab using FITS format, you can use the "fitsread" function to read the FITS file into a variable. Then, you can use the "find" function to specify the conditions for filtering the data. Finally, use the "fitswrite" function to save the filtered data into a new FITS file.

What is FITS format and why is it commonly used in scientific data analysis?

FITS (Flexible Image Transport System) is a standard format used for storing and exchanging scientific data, particularly astronomical data. It is commonly used because it can handle large amounts of data, supports complex data structures, and is self-describing, meaning it contains information about the data it holds.

Can I filter data from multiple FITS files at once in Matlab?

Yes, you can filter data from multiple FITS files at once in Matlab by using a loop to read and filter each file individually. Alternatively, you can combine the data from multiple FITS files into one variable and then filter the combined data.

How can I visualize the filtered data in Matlab using FITS format?

You can visualize the filtered data in Matlab by using the "imshow" function for 2D data or the "surf" function for 3D data. You can also use the "fitsdisp" function to display the information and header of the FITS file containing the filtered data.

Are there any additional tools or packages available for filtering FITS data in Matlab?

Yes, there are several additional tools and packages available for filtering FITS data in Matlab. Some popular ones include the "Image Processing Toolbox" and the "Astronomy and Astrophysics Toolbox", which provide a range of functions specifically designed for working with FITS data.

Similar threads

Replies
1
Views
6K
Replies
4
Views
4K
Replies
2
Views
3K
Replies
1
Views
2K
Replies
1
Views
6K
Replies
1
Views
4K
Replies
8
Views
1K
Back
Top