matlab将txt数据分类,MATLAB读取txt文件,txt里面有字符串和数值两种类型
大家好,又见面了,我是你们的朋友全栈君。
MATLAB读取txt文件,txt里面有字符串和数值两种类型
mip版 关注:96 答案:4 悬赏:30
解决时间 2021-01-29 08:48
已解决
2021-01-28 15:04
MATLAB读取txt文件,txt里面有字符串和数值两种类型,将txt文件读入MATLAB里,并得到一个矩阵。txt文件里面的数据如下:
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
5.0,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.0,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.0,1.4,0.1,Iris-setosa
4.3,3.0,1.1,0.1,Iris-setosa
5.8,4.0,1.2,0.2,Iris-setosa
5.7,4.4,1.5,0.4,Iris-setosa
5.4,3.9,1.3,0.4,Iris-setosa
5.1,3.5,1.4,0.3,Iris-setosa
5.7,3.8,1.7,0.3,Iris-setosa
5.1,3.8,1.5,0.3,Iris-setosa
5.4,3.4,1.7,0.2,Iris-setosa
5.1,3.7,1.5,0.4,Iris-setosa
4.6,3.6,1.0,0.2,Iris-setosa
5.1,3.3,1.7,0.5,Iris-setosa
4.8,3.4,1.9,0.2,Iris-setosa
5.0,3.0,1.6,0.2,Iris-setosa
5.0,3.4,1.6,0.4,Iris-setosa
5.2,3.5,1.5,0.2,Iris-setosa
5.2,3.4,1.4,0.2,Iris-setosa
4.7,3.2,1.6,0.2,Iris-setosa
4.8,3.1,1.6,0.2,Iris-setosa
5.4,3.4,1.5,0.4,Iris-setosa
5.2,4.1,1.5,0.1,Iris-setosa
5.5,4.2,1.4,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
5.0,3.2,1.2,0.2,Iris-setosa
5.5,3.5,1.3,0.2,Iris-setosa
4.9,3.1,1.5,0.1,Iris-setosa
4.4,3.0,1.3,0.2,Iris-setosa
5.1,3.4,1.5,0.2,Iris-setosa
5.0,3.5,1.3,0.3,Iris-setosa
4.5,2.3,1.3,0.3,Iris-setosa
最佳答案
2021-01-28 16:37
function fun()
temdat=load(‘D:\test.txt’);
if temdat== -1
(‘Error opening the file’);
end
A=[temdat(:,1),temdat(:,2),temdat(:,3))];
全部回答
1楼
2021-01-28 18:39
如果没有答案,那就用其他的方法吧。
可以先用ultraedit的 列模式 把后面的删了,然后再用matlab读入
2楼
2021-01-28 17:44
使用textscan函数。
3楼
2021-01-28 17:32
你好!
用csvread或者dlmread都能完成你的要求,textscan也能,但是需要指定格式
如果对你有帮助,望采纳。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/197577.html原文链接:https://javaforall.cn
相关文章
- word在试图打开文件时遇到错误,检查稳定或驱动器文件权限
- matlab中错误使用fmincon,MATLAB中fmincon 函数问题
- matlab中如何求插值点,MATLAB插值「建议收藏」
- matlab画图标签,Matlab绘图
- matlab批量处理excel(CSV)文件数据
- matlab的解决反复激活问题的license.lic文件[通俗易懂]
- MATLAB好玩的代码_Matlab代码
- Matlab中读取txt文件的几种方法[通俗易懂]
- matlab保存所有图,Matlab中图片保存的5种方法
- matlab 读txt数据_数据库文件的读取
- butterworth matlab,Matlab实现Butterworth滤波器
- matlab中importdata无法打开文件_importdata无法打开文件
- 文件上传测试:Windows 创建指定大小的文件
- SQLServer 错误 825 在失败 %d 次(错误: %ls)之后,按偏移量 %#016I64x 对文件“%ls”读取成功。 SQL Server 错误日志和系统事件日志中的其他消息中可能有更详细的信息。 此错误情况威胁到数据库的完整性,因此必须予以更正。 请运行一次完整的数据库一致性检查 (DBCC CHECKDB)。 此错误可能是由多种因素导致的;有关详细信息,请参阅 SQL Server 联机丛书。 故障 处理 修复 支持远程
- 在 Linux 上复制和重命名文件
- 使用Linux Tailq命令快速查看日志文件末尾信息(linuxtailq)
- Linux下快速转换文件编码的实现方法(linux转换编码)
- 恢复Linux XLS文件恢复救星(linuxxls)
- Linux查看文件数量:教你一招(linux 查看文件数量)
- Python高级应用实例对比:高效计算大文件中的最长行的长度