怎样才能实时的将matlab中worksapce里的数据输出到excel
发布网友
发布时间:2022-05-27 03:00
我来回答
共2个回答
热心网友
时间:2024-11-25 05:58
不用那么复杂。如果要输出的变量不太多的话可打开变量,然后全选,再打开excel文件粘贴即可,很简单。如果比较多的话可以先把变量输出为ASCII(txt)文件,然后在excel中导入。
如要将变量a 存成到当前目录下的b.txt文件,可用:save 'b.txt' a -ascii。还有其它参数可参考matlab 的帮助。
SAVE Save workspace variables to disk.
SAVE FILENAME saves all workspace variables to the binary "MAT-file"
named FILENAME.mat. The data may be retrieved with LOAD. If FILENAME
has no extension, .mat is assumed.
SAVE, by itself, creates the binary "MAT-file" named 'matlab.mat'. It is
an error if 'matlab.mat' is not writable.
SAVE FILENAME X saves only X.
SAVE FILENAME X Y Z saves X, Y, and Z. The wildcard '*' can be used to
save only those variables that match a pattern.
ASCII Options:
SAVE ... -ASCII uses 8-digit ASCII form instead of binary regardless
of file extension.
SAVE ... -ASCII -DOUBLE uses 16-digit ASCII form.
SAVE ... -ASCII -TABS delimits with tabs.
SAVE ... -ASCII -DOUBLE -TABS 16-digit, tab delimited.
MAT Options:
SAVE ... -MAT saves in MAT format regardless of extension.
SAVE ... -V4 saves a MAT-file that MATLAB 4 can LOAD.
SAVE ... -APPEND adds the variables to an existing file (MAT-file only).
When using the -V4 option, variables that incompatible with MATLAB 4 are
not saved to the MAT-file. For example, ND arrays, structs, cells, etc.
cannot be saved to a MATLAB 4 MAT-file. Also, variables with names that
are longer than 19 characters cannot be saved to a MATLAB 4 MAT-file.
Use the functional form of SAVE, such as SAVE('filename','var1','var2'),
when the filename or variable names are stored in strings.
See also LOAD, DIARY, FWRITE, FPRINTF, UISAVE, FILEFORMATS.
热心网友
时间:2024-11-25 05:59
采用mlgetmatrix,可以把workspace中的数据存入excel中,并指定位置。
语法
Write contents of MATLAB matrix in Excel worksheet SyntaxWorksheet:MLGetMatrix(var_name, edat)Macro:MLGetMatrix var_name, edatvar_nameName of MATLAB matrix to access. "var_name" (in quotes) directly specifies the matrix name. var_name (without quotes) is an indirect reference: the function evaluates the contents of var_name to get the matrix name, and var_name must be a worksheet cell address or range name.edatWorksheet location where the function writes the contents of var_name. "edat" (in quotes) directly specifies the location and it must be a cell address or a range name. edat (without quotes) is an indirect reference: the function evaluates the contents of edat to get the location, and edat must be a worksheet cell address or range name.
例子
MLGetMatrix("bonds", "Sheet2!C10")
writes the contents of the MATLAB matrix bonds starting in cell C10 of Sheet2. If bonds is a 4-by-3 matrix, data fills cells C10..E13.