Reputation: 938
Say A=[1,3];
.
I want to keep chopping the tail of A
, except that MALAB does not have a "A.pop()
"
I tried to write a code like
for i=m:-1:1;
A=A(1:i-1);
end
but MATLAB says "Subscript indices must either be real positive integers or logicals."
Upvotes: 0
Views: 229
Reputation: 1835
You can also try this I guess:
if length(A) > 1
A(end:end) = []
else
A = []
end
Upvotes: 1
Reputation: 1835
Like this:
if length(A) > 1
A = A(1:length(A)-1)
else
A = []
end
Upvotes: 2