deleting certain data (zeros) from some columns in data without line shift

5 ビュー (過去 30 日間)
Akua Agyeman
Akua Agyeman 2017 年 5 月 1 日
回答済み: Guillaume 2017 年 5 月 1 日
Importing csv file into vector with 2 columns and 200 rows. row 0-358 have zeros in second column. Need to delete all rows that include the zero data so I can plot graphs with the rest. how do i do that

回答 (1 件)

Guillaume
Guillaume 2017 年 5 月 1 日
yourmatrix(any(yourmatrix, :) ==0, :) = []
To delete rows where any column is 0.
Note that by definition a vector has all but one dimension equal to 1. There can not be a vector with 2 columns and 200 rows. This is a matrix.
Also note that if it's just for plotting you don't need to delete anything. Simply use basic indexing in your plot command:
plot(yourmatrix(359:end, :)); %only plot from row 359 onwards

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by