フィルターのクリア

How to combine 4 columns of a table into one new variable and plot it with respect to time?

3 ビュー (過去 30 日間)
I am reading from a file that has 7 columns. I imported it into a table, and I converted T.Var1 into UTC hh:mm:ss:FFF time. T.Var2, T.Var3, T.Var4 and T.Var5 all need to be combined into the variable "source" so I can plot it against timeUTC. Then I would like to have the user change the range of source that is being plotted, where they would be able to chose the range of T.Var2 to be from x to y for example.
clear
clc
close all
[FileName,PathName]=uigetfile(':','Select the LYLOUT file');
T=readtable(fullfile(PathName,FileName));
timeUTC = (datestr(seconds(T.Var1),'HH:mm:ss:FFF'));
sizeTimeUTC = size(timeUTC);
figure('units','normalized','outerposition',[0 0 1 1]);
plot(size,'b')
NumTick = 10;
set(gca,'XTickLabelRotation',45);
xticks=linspace(1,sizeTimeUTC(1),NumTick);
set(gca,'XTick',xticks);
set(gca,'XTickLabel',timeUTC);
How would I go about doing this?
EDIT: Here are the first few rows of the table as requested.
  1. 9601.762212787 33.70270888 -85.26950474 311276.18 0.04 24.4 0xa51
  2. 9601.833916448 33.57688907 -82.95670785 183351.65 2.57 23.5 0x358
  3. 9604.167990668 33.69930560 -83.95209122 38865.36 0.69 9.5 0xb18
  4. 9604.906035077 34.16707482 -85.25531467 12077.34 1.93 13.3 0x358
  5. 9605.012282662 34.20090438 -85.37965820 7081.78 3.71 18.4 0x368
  2 件のコメント
Adam Danz
Adam Danz 2020 年 4 月 13 日
編集済み: Adam Danz 2020 年 4 月 13 日
Why do you need to extract columns from the table? You can plot them and specify the range (ie, rows) directly from the plotting function.
If you need help thinking that through, share the first few rows of your table so we can see what you're working with. See head().
Mark Lupas
Mark Lupas 2020 年 4 月 13 日
編集済み: Mark Lupas 2020 年 4 月 13 日
So I just plot the whole table and specify the range in the plot function?
EDIT: The data variables for an individual source is Var2, Var3, Var4 and Var5. I wish to plot an array of Source against timeUTC, where the user can specifiy the ranges of each data variable in source.

サインインしてコメントする。

採用された回答

Adam Danz
Adam Danz 2020 年 4 月 13 日
Example:
plot(T.Var1, [T.Var2, T.Var3, T.Var4, T.Var5])
If you need to select certain rows,
idx = T.Var1 > x1 & T.Var1 < x2;
plot(T.Var1(idx), [T.Var2(idx), T.Var3(idx), T.Var4(idx), T.Var5(idx)])
  3 件のコメント
Adam Danz
Adam Danz 2020 年 4 月 13 日
There are lots of ways to ask users for input.
etc...
To convert string to datetimes (which are much more useful),
datetime(T.Var1,'InputFormat','hh:mm:ss:SSS')
Mark Lupas
Mark Lupas 2020 年 4 月 13 日
編集済み: Mark Lupas 2020 年 4 月 13 日
Thank you!
Sorry, one last thing. When I try
datetime(T.Var1,'InputFormat','hh:mm:ss:SSS')
it comes up with this error
Numeric input data must be a matrix with three or six columns, or
else three, six, or seven separate numeric arrays. You can also
create datetimes from a single numeric array using the 'ConvertFrom'
parameter.
But when using 'ConvertFrom' there isn't an 'hh:mm:ss:SSSS' option of any kind.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by