MATLAB: Removing data from one vector and corresponding vector

datafor loop

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 20000×1, 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

Best Answer

"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) = [];