MATLAB Answers

L
0

Removing data from one vector and corresponding vector

L
さんによって質問されました 2018 年 11 月 14 日
最新アクティビティ Adam Danz
さんによって コメントされました 2018 年 11 月 15 日
I want to remove the outliers from a couple sets of data like the one shown graphed below. For each I have two separate vectors (temp) and (time) of equal size and am plotting temp vs. time. I can understand how I would remove my temperature outliers, however because these are 2 separate vectors (both 20000x1, for example) how do I also remove the corresponding time row? Do I need to combine them into a single matrix or is there another way to do this? Here's the plotting section of my code with the outliers presently included. Thank you!
%A15 Probe 1
figure(1)
plot(Time_15_35, T_15_35);%.35
hold on
plot(Time_15_83, T_15_83);%.83
plot(Time_15_91, T_15_91);%.91
plot(Time_15_139, T_15_139);%1.39
ylim([248 257])
legend('.35','.83','.91','1.39');
title('Apollo 15 Probe 1')
hold off
%A15 Probe 2
figure(2)
plot(Time_15_49, T_15_49)%.49
hold on
plot(Time_15_97, T_15_97)%.97
ylim([247 255])
legend('.49','.97')
title('Apollo 15 Probe 2')
hold off
%A17 Probe 1
figure(3)
plot(Time_17_130, T_17_130) %1.30
hold on
plot(Time_17_177, T_17_177) %1.77
plot(TIME_A_17_1_2_final,T_F_17_1_2_185); %1.85
plot(TIME_A_17_1_2_final,T_F_17_1_2_234); %2.33, data by day for '75-77 (not shown)
ylim([255 259])
legend('1.30','1.77','1.85','2.33')
title('Apollo 17 Probe 1')
hold off
%A17 Probe 2
figure(4)
plot(Time_17_131, T_17_131) %1.31
hold on
plot(Time_17_178, T_17_178) %1.77
plot(TIME_A_17_2_2/msyr-OG_T_A_17_1_2+in_17,T_F_17_2_2_234); %2.34
plot(TIME_A_17_2_2/msyr-OG_T_A_17_1_2+in_17,T_F_17_2_2_186); %1.86
legend('1.31','1.78','2.34','1.86')
ylim([255 258])
title('Apollo 17 Probe 2')
hold off
Screen Shot 2018-11-14 at 2.08.12 PM.png

  0 件のコメント

サインイン to comment.

タグ

1 件の回答

Adam Danz
回答者: Adam Danz
2018 年 11 月 14 日
編集済み: Adam Danz
2018 年 11 月 15 日
 採用された回答

"I can understand how I would remove my temperature outliers, however because these are 2 separate vectors (both 20000x1, for example) how do I also remove the corresponding time row?"
The exact steps you take will depend on how you're detecting and removing the outliers from your temperature data. The general idea is that you'll use a logical vector or a vector of row numbers to identify the outliers in the temperature vector and you'll use the same index vector to remove rows from your time vector.
Exmaple
TF = isoutlier(temperature); %matlab 2017a or later
temperature(TF) = [];
time(TF) = [];

  3 件のコメント

L
2018 年 11 月 14 日
I think that worked great, thank you!
L
2018 年 11 月 15 日
Is there a reason it would result in the vectors being two different sizes? This method worked for one data set and not for another. The vectors started as equal lengths and after I ran this the vectors are no longer the same length.
Adam Danz
2018 年 11 月 15 日
There are 3 vectors in my solution and I'm not sure what vectors you found to be unequal in length.
  • temperature
  • time
  • TF
If temperature and time are not the same lenght before searching for outliers, they can't be paired at all.
TF should always be the same length as temperature (or whatever input is used).
If you're using the same TF vector to eliminate data from temperature and time, they absolutely should remain the same length. So something's wrong in the code.

サインイン to comment.



Translated by