matlab如何导入csv文件及matlab支持的数据格式,相应函数

本文介绍了如何在MATLAB中使用csvread和importdata函数导入CSV文件,以及MATLAB支持的各种数据格式,包括MAT、CSV、DAT、DLM、TAB等,并提到了Excel、Lotus 123、CDF、FITS、HDF等科学数据格式,以及各种图像和音频格式的读取方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


 

使用csvread函数读取
M = csvread('filename')
M = csvread('filename', row, col)
M = csvread('filename', row, col, range)


输出用:

csvwrite('filename',M)
csvwrite('filename',M,row,col)


实际使用时importdata()函数比较方便,从Excel另存数据为"csv"文件,matlab在读取时容易产生如下错误:

??? Error using ==> dlmread at 145
Mismatch between file and format string.
Trouble reading number from file (row 1, field 2) ==> " -0.

Error in ==> csvread at 52
    m=dlmread(filename, ',', r, c);


 Data formats                     Command    Returns
    MAT  - MATLAB workspace         load       Variables in file.
    CSV  - Comma separated numbers  csvread    Double array.
    DAT  - Formatted text    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值