Deleting Zero Rows - Matlab Noob

I have a matrix A where the first column consists of unique positive whole numbers and zeros. I want to delete the rows where the values are zero.
A = csvread('Truss Data.csv',1,0);
B = sortrows(A(:,1:7)); %I'm sorting them to make sure they are sequential%
A =
1 0 0 0 0 1 1 1 29000 10 1 2
2 30 0 0 -120 0 0 2 29000 10 2 3
3 60 0 0 0 0 0 3 29000 10 3 4
4 90 0 0 0 0 1 4 29000 10 1 5
5 30 40 90 0 0 0 5 29000 10 2 5
6 60 40 0 0 0 0 6 29000 10 3 5
0 0 0 0 0 0 0 7 29000 10 3 6
0 0 0 0 0 0 0 8 29000 10 4 6
0 0 0 0 0 0 0 9 29000 10 5 6
B =
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
1 0 0 0 0 1 1
2 30 0 0 -120 0 0
3 60 0 0 0 0 0
4 90 0 0 0 0 1
5 30 40 90 0 0 0
6 60 40 0 0 0 0
How do I remove the rows in B where the first column of B has zeros? I want:
B =
1 0 0 0 0 1 1
2 30 0 0 -120 0 0
3 60 0 0 0 0 0
4 90 0 0 0 0 1
5 30 40 90 0 0 0
6 60 40 0 0 0 0

1 件のコメント

Mark
Mark 2013 年 3 月 28 日
*Note - the above matrix A doesn't show correctly on this webpage. There were too many columns to fit.

サインインしてコメントする。

 採用された回答

Cedric
Cedric 2013 年 3 月 28 日

4 投票

B(B(:,1)==0,:) = [] ;

1 件のコメント

Dattaprasad Sh
Dattaprasad Sh 2020 年 2 月 20 日
編集済み: Dattaprasad Sh 2020 年 2 月 20 日
works well. thank you!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

製品

質問済み:

2013 年 3 月 28 日

編集済み:

2020 年 2 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by