A numeric or double convertible argument is expected- How to plot from 'readtable'

1 visualización (últimos 30 días)
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)

Respuestas (1)

Cris LaPierre
Cris LaPierre el 11 de Feb. de 2021
Editada: Cris LaPierre el 11 de Feb. de 2021
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)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by