Concatenating in a new matrix from inside a while loop
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
KSSV
on 4 Oct 2017
Edited: KSSV
on 4 Oct 2017
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;
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!