您的位置:首页 > 编程语言 > MATLAB

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

2011-06-29 23:10 1756 查看
 

使用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           importdata Double array.
    DLM  - Delimited text           dlmread    Double array.
    TAB  - Tab separated text       dlmread    Double array.

   Spreadsheet formats
    XLS  - Excel worksheet          xlsread    Double array and cell array.
    WK1  - Lotus 123 worksheet      wk1read    Double array and cell array.

   Scientific data formats
    CDF  - Common Data Format               cdfread    Cell array of CDF records
    FITS - Flexible Image Transport System  fitsread   Primary or extension table data
    HDF  - Hierarchical Data Format         hdfread    HDF or HDF-EOS data set

   Movie formats
    AVI  - Movie                    aviread    MATLAB movie.

   Image formats
    TIFF - TIFF image               imread     Truecolor, grayscale or indexed image(s).
    PNG  - PNG image                imread     Truecolor, grayscale or indexed image.
    HDF  - HDF image                imread     Truecolor or indexed image(s).
    BMP  - BMP image                imread     Truecolor or indexed image.
    JPEG - JPEG image               imread     Truecolor or grayscale image.
    GIF  - GIF image                imread     Indexed image.
    PCX  - PCX image                imread     Indexed image.
    XWD  - XWD image                imread     Indexed image.
    CUR  - Cursor image             imread     Indexed image.
    ICO  - Icon image               imread     Indexed image.
    RAS  - Sun raster image         imread     Truecolor or indexed.
    PBM  - PBM image                imread     Grayscale image.
    PGM  - PGM image                imread     Grayscale image.
    PPM  - PPM image                imread     Truecolor image.
 
   Audio formats
    AU   - NeXT/Sun sound           auread     Sound data and sample rate.
    SND  - NeXT/Sun sound           auread     Sound data and sample rate.
    WAV  - Microsoft Wave sound     wavread    Sound data and sample rate.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息