Filtering Data with Matlab in FITS Format

  • Thread starter Thread starter TFM
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary

Discussion Overview

The discussion revolves around using Matlab to filter data originally in FITS format, focusing on sorting and filtering variables based on specific criteria, particularly redshift values. Participants share their attempts at coding solutions and the challenges they face with data structures and indexing in Matlab.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes their goal of filtering data with a redshift less than a specified number using Matlab.
  • Another participant notes that the data is in a 1x55 table, which complicates filtering due to matrix dimension errors.
  • A participant mentions converting the data into a structure and questions whether the filter command works with structures, reporting a matrix error when attempting to filter.
  • One response suggests that the issue may stem from the indexing of the data structure, indicating that mismatched lengths between the filtered data and the original structure can lead to errors.

Areas of Agreement / Disagreement

Participants do not appear to reach a consensus on the best approach to filter the data, as multiple issues and potential solutions are discussed without resolution.

Contextual Notes

Participants express uncertainty regarding the proper handling of data structures and indexing in Matlab, with specific reference to matrix dimension errors and the behavior of the filter command with structures.

Who May Find This Useful

This discussion may be useful for individuals working with Matlab for data analysis, particularly those dealing with FITS format data and encountering similar filtering and indexing challenges.

TFM
Messages
1,016
Reaction score
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
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
 
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
 
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
 

Similar threads

  • · Replies 14 ·
Replies
14
Views
9K
  • · Replies 4 ·
Replies
4
Views
5K
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 2 ·
Replies
2
Views
9K