先說一下字串,字串在matlab中需要加單引號,你直接使用newData1 = importdata(DOW.txt);
matlab便會將DOW.txt看成是變數,但是importdata需要一個包含檔名的字串變數,但是DOW.txt不知道是什麼東西,所以會出現??? Undefined variable "DOW" or class "DOW.txt".
正確的使用方法是:
newData1 = importdata("DOW.txt");
或者
path="DOW.txt"
newData1 = importdata(path);
不過importdata不支援字尾名為txt檔案,其支援的檔案字尾有:
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.
先說一下字串,字串在matlab中需要加單引號,你直接使用newData1 = importdata(DOW.txt);
matlab便會將DOW.txt看成是變數,但是importdata需要一個包含檔名的字串變數,但是DOW.txt不知道是什麼東西,所以會出現??? Undefined variable "DOW" or class "DOW.txt".
正確的使用方法是:
newData1 = importdata("DOW.txt");
或者
path="DOW.txt"
newData1 = importdata(path);
不過importdata不支援字尾名為txt檔案,其支援的檔案字尾有:
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.