本文介绍了无法从表创建数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用MATLAB加载外部CSV文件.

I'm trying to load an external CSV file using MATLAB.

我设法使用webread下载了该文件,但我只需要其中一部分即可.

I managed to download it using webread, but I only need a subset of the columns.

我尝试过

Tb = webread('https://datahub.io/machine-learning/iris/r/iris.csv');     
X = [sepallength sepalwidth petallength petalwidth];

但是我不能以这种方式形成X,因为无法识别名称.如何正确创建X?

But I cannot form X this way because the names are not recognized. How can I create X correctly?

推荐答案

Tb = webread('https://datahub.io/machine-learning/iris/r/iris.csv');

产生一个具有列名table对象,您稍后尝试访问,就好像它们是工作区变量一样,不是.相反,您应该修改代码以使用:

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];

这篇关于无法从表创建数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 16:57