Hi all,
I have a 267x34 matrix. Now I want to delete certain columns within MATLAB.
For instance if I want to delete the 3rd column, 4th column, 8th column, 14th column and 33 column. How would I write this in a code where they all get delete simultaneously?
Thanks,

댓글 수: 2

Mayank Malaviya
Mayank Malaviya 2016년 9월 2일
편집: Mayank Malaviya 2016년 9월 2일
B = horzcat(A(1:end,1:n-1),A(1:end,n+1:end)); % A is your matrix and n is the column which is to be removed
Fabian Lischka
Fabian Lischka 2018년 11월 26일
FWIW, above comment from 2016-09-02 does not address the question (deleting multiple columns), and is furthermore possibly a fairly inefficient way of doing what it does (deleting one column).

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

추가 답변 (1개)

Reza Zakernejad
Reza Zakernejad 2017년 10월 12일
편집: Reza Zakernejad 2017년 10월 12일

8 개 추천

A(:,[m n p...])=[]; % A input matrix and m n p are #columns to be deleted

댓글 수: 1

Not sure why this is not the "Accepted Answer". It does exactly what I want to. I have several column indexes of outliers which I found by comparing against a threshold. Using this answer, I can simply put my list into the [] and poof outliers are gone.
outliers = find (errorDist > thresholdValue); % list of outliers
M(:,outliers) = []; % *poof!* clean matrix

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2012년 7월 15일

댓글:

2019년 12월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by