How do I export four variables of different sizes to an excel, txt or csv file?

조회 수: 13 (최근 30일)
Hello, I have four variables, which I want to save to either excel, txt or csv. Which file format doesn't matter, it only needs to be able to save this file in a database and load the data later on again. Of the four variables, three have a size of 1x1 double and one has a size of 10x2 double.
Is there a way to export this data to one file, maybe even with the variable name?
  댓글 수: 2
Jannis Holtkoetter
Jannis Holtkoetter 2020년 10월 31일
When I try that it only gives me the error: Undefined function 'store' for input arguments of type 'double'.

댓글을 달려면 로그인하십시오.

채택된 답변

Gouri Chennuru
Gouri Chennuru 2020년 11월 6일
Hi Jannis,
As a workaround you can use the following code snippet as an example,
a = 1 % 1*1
b = 2 % 1*1
c = 3 % 1*1
d = randn(10,2) % 10 *2
e = {a b c d} % storing all the variables in a single cell
writecell(e,'filename.xls') % eexporting the data into excel
Hope this Helps!
  댓글 수: 1
Jannis Holtkoetter
Jannis Holtkoetter 2020년 11월 8일
Hey, yeah it is a good workaround. It exports all data into one row of excel.
However, I already created another workaround which works aswell: I simply add a few NaNs to the 1x1 array, so that they have the same length as the 10X2 matrix. Then I save everything in a table and export to excel. The NaNs are not being displayed in excel.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by