フィルターのクリア

Hello everyone. I have a file .data and I need to convert it to an array. How can this be done?

1 回表示 (過去 30 日間)
Axel
Axel 2022 年 9 月 18 日
回答済み: Chunru 2022 年 9 月 18 日
I opened the file using "importdata" function, but it was created as a cell and I need it to be an array because I will applying the Principal component analysis.
The data in this file appears in this format
'5.1,3.5,1.4,0.2,Iris-setosa'
'4.9,3.0,1.4,0.2,Iris-setosa'
'4.7,3.2,1.3,0.2,Iris-setosa'
'4.6,3.1,1.5,0.2,Iris-setosa'
I'm using the Iris flower data set or Fisher's Iris data set, this is a multivariate data set that consists of 50 samples from each of three species of Iris (Iris setosa, Iris virginica and Iris versicolor).
Link for dataset: https://archive.ics.uci.edu/ml/datasets/iris

回答 (2 件)

Chunru
Chunru 2022 年 9 月 18 日
websave("iris.dat", "https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data")
ans = '/users/mss.system.N88I3a/iris.dat'
x = readtable("iris.dat")
x = 150×5 table
Var1 Var2 Var3 Var4 Var5 ____ ____ ____ ____ _______________ 5.1 3.5 1.4 0.2 {'Iris-setosa'} 4.9 3 1.4 0.2 {'Iris-setosa'} 4.7 3.2 1.3 0.2 {'Iris-setosa'} 4.6 3.1 1.5 0.2 {'Iris-setosa'} 5 3.6 1.4 0.2 {'Iris-setosa'} 5.4 3.9 1.7 0.4 {'Iris-setosa'} 4.6 3.4 1.4 0.3 {'Iris-setosa'} 5 3.4 1.5 0.2 {'Iris-setosa'} 4.4 2.9 1.4 0.2 {'Iris-setosa'} 4.9 3.1 1.5 0.1 {'Iris-setosa'} 5.4 3.7 1.5 0.2 {'Iris-setosa'} 4.8 3.4 1.6 0.2 {'Iris-setosa'} 4.8 3 1.4 0.1 {'Iris-setosa'} 4.3 3 1.1 0.1 {'Iris-setosa'} 5.8 4 1.2 0.2 {'Iris-setosa'} 5.7 4.4 1.5 0.4 {'Iris-setosa'}

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2022 年 9 月 18 日
Use the recommended data import fcns, such as readtable() or readmatrix() that would import your data into a Table or Matrix array, respectively.

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by