I am creating a table by reading through a file, the table contains the following:
Var1 Var2 Var3 Var4 Var5 9728.015877288 34.21601656 -85.26319543 6120.27 0.71 9728.100523585 34.19514296 -85.29652054 2121.33 2.60 9728.162613281 33.67647324 -83.90831590 2601.09 2.36 9728.178688810 34.17953039 -85.35196003 8092.13 4.57 9728.187776872 34.17839105 -85.35730262 8066.19 1.53
Var1 is time in seconds, and I am converting it to hh:mm:ss:SSS. Each row of the table is a "source" that contains the data Var1, Var2, Var3, Var4, Var5. I want to plot converted time vs source, where the user can input the ranges of each variable.
[FileName,PathName]=uigetfile(':','Select the LYLOUT file');T=readtable(fullfile(PathName,FileName));figure('units','normalized','outerposition',[0 0 1 1]); prompt1 = {'(1) Enter the lower range of latitude where ' + string(min(T.Var2)) + ' is the minimum: ','(2) Enter upper range of latitude where ' + string(max(T.Var2)) + ' is the maximum: '};dlgtitle1 = 'Latitude Range Input';dims = [1 35];answer1 = str2double(inputdlg(prompt1,dlgtitle1,dims));prompt2 = {'(1) Enter the lower range of longitude where ' + string(min(T.Var3)) + ' is the minimum: ','(2) Enter upper range of longitude where ' + string(max(T.Var3)) + ' is the maximum: '};dlgtitle2 = 'Longitude Range Input';answer2 = str2double(inputdlg(prompt2,dlgtitle2,dims));prompt3 = {'(1) Enter the lower range of altitude where ' + string(min(T.Var4)) + ' is the minimum: ','(2) Enter upper range of altitude where ' + string(max(T.Var4)) + ' is the maximum: '};dlgtitle3 = 'Altitude Range Input';answer3 = str2double(inputdlg(prompt3,dlgtitle3,dims));prompt4 = {'(1) Enter the lower range of reduced chi squared where ' + string(min(T.Var5)) + ' is the minimum: ','(2) Enter upper range of reduced chi squared where ' + string(max(T.Var5)) + ' is the maximum: '};dlgtitle4 = 'Reduced chi squared Range Input';answer4 = str2double(inputdlg(prompt4,dlgtitle4,dims));idx = T.Var2 >= answer1(1) & T.Var2 <= answer1(2) & T.Var3 >= answer2(1) & T.Var3 <= answer2(2) & T.Var4 >= answer3(1) & T.Var4 <= answer3(2) & T.Var5 >= answer4(1) & T.Var5 <= answer4(2);timeUTC = seconds(T.Var1);timeUTC.Format = 'hh:mm:ss.SSS';plot(timeUTC(idx), [T.Var2(idx), T.Var3(idx), T.Var4(idx), T.Var5(idx)])ylim([0 inf]);grid minor;xlabel('UTC Time');ylabel('Sources');title('Time vs Sources');
But instead of combining Var2, Var3, Var4 and Var5 into a variable it plots all of the variables at once. How would I plot the time vs source?
Best Answer