A numeric or double convertible argument is expected- How to plot from 'readtable'
2 次查看(过去 30 天)
显示 更早的评论
Dear scholars,
I have a dataset of numbers in Excel as .csv file which is attached. I need to plot the first coulumn as the 'x' values and the third column values as the 'y' values. Apparently there is a problem with the 3rd column and MATLAB get's this column as string (not numeric values). Any suggestions? The Excel and the code are both attached.
Thanks in advacne!
clc
clear all
close all
C = readtable('e1.csv')
t = C(:,1)
v1 = C(:,3)
%v = [12.5, 16.17, 18.79, 13.59, 12.58, 12.46, 12.67, 12.5, 12.73, 13.36, 12.56, 12.6, 12.62, 12.98, 13.87, 13.82, 13.71, 13.78, 14.27];
numel(v)
numel(t)
plot(t, v)
0 个评论
回答(1 个)
Cris LaPierre
2021-2-11
编辑:Cris LaPierre
2021-2-11
See this page on how to access data in a table. Your syntax is returning a table. You need an array.
Use curly braces
t = C{:,1}
v = C{:,3}
or dot notation
t = C.(1)
v = C.(3)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!