I'm trying to load an external CSV file using MATLAB.
I managed to download it using webread
, but I only need a subset of the columns.
I tried
Tb = webread('https://datahub.io/machine-learning/iris/r/iris.csv');
X = [sepallength sepalwidth petallength petalwidth];
But I cannot form X
this way because the names are not recognized. How can I create X
correctly?
The line
Tb = webread('https://datahub.io/machine-learning/iris/r/iris.csv');
Produces a table
object with column names you later try to access as if they were workspace variables - which they aren't. Instead, you should modify your code to use:
X = [Tb.sepallength Tb.sepalwidth Tb.petallength Tb.petalwidth];