Converting Table to Readable Format for Scatter Plot

조회 수: 17 (최근 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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by