Converting Table to Readable Format for Scatter Plot

18 ビュー (過去 30 日間)
David Forgy
David Forgy 2022 年 10 月 14 日
回答済み: VBBV 2022 年 11 月 6 日
Hi!
It's been a while since I've last used MatLab so I apologize in advance if I use maybe some wrong terminology or if this has been solved and I just couldn't find it on my searches.
The issue I'm coming into is I had to import data from a text file, which has its own very weird format into a useable ScatterPlot Graph.
I used the import function from Excel with Tab Delimiter, saved it as an .xlsx file, then uploaded that data into matlab via readtable(), and then transposed the data.
The problem I'm running into is how to use the Top Row as my X variable, which is currently timestamped in '4:08:45 PM' and increases in 5 second intervals ('4:08:50 PM', '4:08:55 PM', etc). Then take the selected rows as needed for the Y-Data. (Voltage, Current, Power, repeating).
I know I'm forgetting or doing something wrong, but have hit a dead end on searches. The error currently getting output is "Input arguments must be numeric, datetime, duration or categorical." I've tried several different things, and I'm not sure what course would be the best line of action to take.
T1 = readtable('Data.xlsx');
T1_Data = table2array(T1);
T1_Data = T1_Data';
T1_Data = cell2table(T1_Data);
scatter(T1_Data{:,1}, T1_Data{:,3});

回答 (2 件)

KSSV
KSSV 2022 年 10 月 14 日
T1 = readtable('Data.xlsx');
scatter(T1.(1), T1.(3));
  1 件のコメント
David Forgy
David Forgy 2022 年 10 月 14 日
Unforuntely this gives me the same error.
Also, the table really does need to be transposed. Before the Transpose the format given looks like:

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


VBBV
VBBV 2022 年 11 月 6 日
T1 = readtable('Data.xlsx');
T1_Data = table2array(T1); % this converts cell to numeric
T1_Data = T1_Data';
% T1_Data = cell2table(T1_Data); % this converts numeric to cell
scatter(T1_Data(:,1), T1_Data(:,3));
Use numeric data for scatter plot

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by