필터 지우기
필터 지우기

Delete rows from matrix

조회 수: 2 (최근 30일)
Amal
Amal 2014년 3월 4일
댓글: Amal 2014년 3월 4일
Hallo,I need help!
I have 110 matrix 64 line x 2200 column and I would like to delete some columns from each matrix, so I am obliged to use loops for each matrix. I am looking for a predefined function to delete the columns. This is a small algorithm explaining what I mean:
for i=1:110
delete( matrix(:,j:j+5)) from matrix;
end
  댓글 수: 2
Image Analyst
Image Analyst 2014년 3월 4일
편집: Image Analyst 2014년 3월 4일
WHY are you obligated to use loops rather than the vectorized method the others suggested? Do you just think you do (because you don't know how to use MATLAB's vectorization capability), or did your professor/instructor mandate it?
Amal
Amal 2014년 3월 4일
I have other instruction in the same loop and I need each iteration a matrix, each matrix contains the same columns, but in different order. I think my problem is solved finally :) I am waiting for matlab execution to verify my matrix. I used this instruction: matrix(:,j:j+5)=[];
thank you for your help :)

댓글을 달려면 로그인하십시오.

채택된 답변

Giorgos Papakonstantinou
Giorgos Papakonstantinou 2014년 3월 4일
편집: Giorgos Papakonstantinou 2014년 3월 4일
IN the title you mention rows. In the question you mention columns. example:
A1=randi(10,64, 2200);
A2=randi(10,64, 2200);
A3=randi(10,64, 2200);
...
An=randi(10,64, 2200);
mat=[A1;A2;A3;...An];
startcolumn=11;
step=11;
mat(:,[startcolumn:step:end])=[]
  댓글 수: 1
Amal
Amal 2014년 3월 4일
thank you so much, I used the last instruction from the beginning, but it didn't work, but after restarting MATLAB it worked ;)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Iain
Iain 2014년 3월 4일
To "delete"
matrix = eye(5);%5x5 identity matrix
list_o_cols_to_delete = [1 3 5];
matrix(:,list_o_cols_to_delete) = []
To only use the bits you want:
matrix = eye(5);%5x5 identity matrix
list_o_cols_to_use = [1 3 5];
used = matrix(:,list_o_cols_to_use)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by