Concatenating in a new matrix from inside a while loop
조회 수: 3 (최근 30일)
이전 댓글 표시
Hiee.. I am trying store the new values of TP in a new matrix after some TP values are deleted inside the loop as the conditions are met. Then again, after the inside while loop ends, i want to set new conditions and perform operation on the old TP values and keep storing it in new matrix to perform some other condition on the new TP value and keep doing it. I am not able to find the right way of doing it. I would be very grateful for anyone's help expert in matlab. Thank you
s=1;
k=1;
num_pos= 1;
che= [0.01:0.05:10]';
size(che);
while s < length(che)
TP=X; %X is a n by 2 matrix
while k < length(D)
if D(num_pos,1) > abs(che(s)*xstd+xmean)
TP(num_pos,:)=[];
else
TP(num_pos,:) = X(num_pos,:);
num_pos = num_pos+1;
end
k = k+1;
% want to store the new TP values in a matrix(e.g "newmatrix") of n1 by 2
sensitivity(s) = (length(newmatrix)/250);
end
% bring my Old TP value which is equal to X ( n by 2 ) matrix
s=s+1;
end
댓글 수: 0
답변 (1개)
KSSV
2017년 10월 4일
편집: KSSV
2017년 10월 4일
YOu may initialize your newmatrix as nx2x2 matrix, stroe oldTP at 1 and new TP at 2. The below one will work with few changes accordingly.
s=1;
k=1;
num_pos= 1;
che= [0.01:0.05:10]';
size(che);
n=600;
count1 = 0 ;
sensitivity = cell([],[]) ;
while s < length(che)
count1 = count1+1 ;
count2 = 0 ;
TP=X; %X is a n by 2 matrix
newmatrix(:,:,1) = TP ;
while k < length(D)
count2 = count2+1 ;
if D(num_pos,1) > abs(che(s)*xstd+xmean)
TP(num_pos,:)=[];
else
TP(num_pos,:) = X(num_pos,:);
num_pos = num_pos+1;
end
k = k+1;
new_matrix= TP ;
% want to store the new TP values in a matrix(e.g "newmatrix") of n1 by 2
sensitivity{count1,count2} = (length(new_matrix)/250);
end
% bring my Old TP value which is equal to X ( n by 2 ) matrix
TP = newmatrix(:,:,1) ;
s=s+1;
end
sensitivity;
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Global or Multiple Starting Point Search에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!