Filter löschen
Filter löschen

Can't Remove Rows

1 Ansicht (letzte 30 Tage)
Jay
Jay am 25 Jun. 2019
Kommentiert: Jay am 26 Jun. 2019
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?

Akzeptierte Antwort

Jeroen vD
Jeroen vD am 25 Jun. 2019
Instead of
A(rowCount:row,col) = []
use
A(rowCount:row, :) = []
  1 Kommentar
Jay
Jay am 26 Jun. 2019
Thank you Jeroen.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by