Can't Remove Rows

조회 수: 4 (최근 30일)
Jay
Jay 2019년 6월 25일
댓글: Jay 2019년 6월 26일
I am trying to remove rows using the following code.
% Hypothetical read in from an excel spreadsheet
% 20 rows of values and only first 10 rows have useable data
A = randi([0,30],10,10)
A (10:20,10) = zeros
%% Determining Useable Data
% Array dimension
[row,col] = size(A)
% Row count for element values
rowCount = 0
% Assess array A for numeric values in elements of column 1
for i=1:row
if A(i,1) ~= 0
%logAss(i,1) = 1
rowCount = rowCount + 1
else
end
end
% Delete rows of no value
A(rowCount:row,col) = []
% Where following error thrown:
% "A null assignment can have only one non-colon index.
% Error in Test1 (line 32)
% A(rowCount:row,col) = []"
How do I redimension the array using variables?

채택된 답변

Jeroen vD
Jeroen vD 2019년 6월 25일
Instead of
A(rowCount:row,col) = []
use
A(rowCount:row, :) = []
  댓글 수: 1
Jay
Jay 2019년 6월 26일
Thank you Jeroen.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by