How can i eliminate a few column?

1 view (last 30 days)
i have 10 pcs of 200 by 200 dim of images. then i formed a matrix with the 10 by 40000. some of the column consist the same value from top to bottom, therefore i want to eliminate or replace it with 0. i have try repmat and std or even mean. i want to have only the significant features of my image so that i can perform PCA using princomp function.tq 4 ur help.
  2 Comments
maysarah sulaiman
maysarah sulaiman on 25 May 2013
oh actually i typed it wrongly just now, i have amend my question.tq

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 25 May 2013
Try this:
% Generate sample data:
columns = 18; % Could be 40000 or size(m, 2)
rows = 4;
m = randi(4, rows, columns)
% ----- HERE'S THE MAIN CODE ---------------------------
% Find out where the entire column is the same number
% by taking the mean of the column and seeing
% if the mean of the column is the same as the first row.
columnAllTheSame = mean(m) == m(1,:)
% Set those that are all the same to 0:
m(:, columnAllTheSame) = 0
  6 Comments
Image Analyst
Image Analyst on 26 May 2013
Edited: Image Analyst on 26 May 2013
I don't understand what this means "returns me all column 0." There is no column 0 - there are columns 1 through size(m, 2). Or, are you saying that all columns are zero for every row in the column? In essence, the entire matrix is zero? I don't see how that can be. Can you give an example of the matrix you are having trouble with? My code, as always, is very well commented so I don't know how much more I can elaborate. What is confusing to you?
maysarah sulaiman
maysarah sulaiman on 27 May 2013
Edited: maysarah sulaiman on 27 May 2013
urm i just realize that i define it wrongly. i got it already.thanks a lot.

Sign in to comment.

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 25 May 2013
Use unique function
help unique
  1 Comment
maysarah sulaiman
maysarah sulaiman on 25 May 2013
Edited: maysarah sulaiman on 25 May 2013
i have try but this don't give me the ans that i want. My data is actually images, therefore i still need to retain the character of each row.

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!