sorter and faster code
이전 댓글 표시
Hello everyone, I am quite new in Matlab and I need your help. Can someone tell me how can I make this code shorter and (maybe) faster? I have to repeat the code for several elements. Thank you!
load ('TableScatter_B6.mat')
TableScatter_B6.LIVETIME= cellfun(@str2num,TableScatter_B6.LIVETIME);
array=table2array(TableScatter_B6);
x=array(:,13);%LIVETIME
Rb=array(:,3);Sr=array(:,4);Y=array(:,5);Zr=array(:,6);Nb=array(:,7);Mo=array(:,8);I=array(:,9);
Cs=array(:,10);Ba=array(:,11);U=array(:,12);LIVETIME=array(:,13);
meanValue_Sr = mean(Sr);
absoluteDeviation_Sr = abs(Sr - meanValue_Sr);
mad_Sr = median(absoluteDeviation_Sr);
sensitivityFactor = 6 ;
thresholdValue_Sr = sensitivityFactor * mad_Sr;
outlierIndexes_Sr = abs(absoluteDeviation_Sr) > thresholdValue_Sr;
outliers_Sr = Sr(outlierIndexes_Sr);
nonOutliers_Sr = Sr(~outlierIndexes_Sr);
T_V_Sr=TableScatter_B6(:,[4,13])
for w=1:length(Sr);
for j=1:length(nonOutliers_Sr);
if nonOutliers_Sr(j)==Sr(w,1);
Tnew_Sr(j,:)=T_V_Sr(w,:) ;
end
end
end
댓글 수: 1
Today I've formatted the code for you. Please use the "{} Code" button by your own in the future - thanks.
You forgot to explain the purpose of the code. In the nested loop, Tnew_Sr(j,:) can be overwritten repeatedly by different T_V_Sr(w,:) this is surely a waste of time, but it is not clear, if this wanted or a bug.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Performance and Memory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!