How to delete a particular array and again in the next step create it as a new array in a for loop

Hello,
I am using an array to save the values that are greater than a threshold from a particualr set of values in a for loop.
Can I know how to delete the previous array values and size.And in the next step I want to create it as new array with new size and intialising it to zeros for each iteration of for loop.
Thanks.

댓글 수: 4

Here it is
for i=1:500:length(full_signal)-6000
x1=full_signal(1,i:i+499);
input(1,i:i+499)=full_signal(1,i:i+499);
nonZeroElements = x1 > 0.02;
diffPattern = diff(nonZeroElements);
humpStarts = strfind(diffPattern, [1, 0]);
if (length(humpStarts)==2)
needed{a}(1,1:length(next))=next(1,1:length(next));
needed{a}(1,length(next)+1:(length(next)+humpStarts(1)))=x1(1,1:humpStarts(1));
a=a+1;
needed{a}(1,1:(humpStarts(2)-humpStarts(1)))=x1(1,humpStarts(1)+1:humpStarts(2));
a=a+1;
%---Here I want to delete the prvious array next and want to create it as snew---%
next(1,1:length(x1)-humpStarts(2))=x1(1,humpStarts(2)+1:length(x1));
elseif(length(humpStarts)==1)
needed{a}(1,1:length(next))=next(1,1:length(next));
needed{a}(1,length(next)+1:(length(next)+humpStarts(1)))=x1(1,1:humpStarts(1));
a=a+1;
%---Here I want to delete the prvious array next and want to create it as snew---%
next(1,1:length(x1)-(humpStarts(1)))=x1(1,humpStarts(1)+1:length(x1));
else
%---Here I want to delete the prvious array next and want to create it as snew---%
next(1,1:length(x1))=x1(1,1:length(x1));
end;
end;
I mean give a short example and explain what you want to achieve
Assume if the size of next array is 1x500 then the values will be stored into needed{1}
length(humpStarts)==1)
needed{a}(1,1:length(next))=next(1,1:length(next));
in the next step here it will store the remaining values from 501 to index at which hump occurs
needed{a}(1,length(next)+1:(length(next)+humpStarts(1)))=x1(1,1:humpStarts(1));
a=a+1;
In the next step if the values from humpStarts(1)+1:length(x1) are 15 then the nextarray here is replacing its first 15 values with the 15 values from x1 and leaving the remaining previous values from 15+1 to the length of previous next array.
next(1,1:length(x1)-(humpStarts(1)))=x1(1,humpStarts(1)+1:length(x1));
But here in the last step I just want to save the current 15 values from x1 in the next array making its size limited to only 15 and I don't even want to have zero values from the next 15 values(I mean I want to have the size of next array that can only fit the remaning values from humpStarts(1)+1:length(x1) .

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

태그

질문:

2014년 1월 14일

댓글:

2014년 1월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by