How to convert a large set of variables in the MATLAB workspace into an Excel file?

2 ビュー (過去 30 日間)
Missael Hernandez
Missael Hernandez 2021 年 9 月 24 日
コメント済み: Missael Hernandez 2021 年 9 月 24 日
I want to take my Workspace variables and download them as an Excel file. Here's how I am doing it
% Clean your workspace
clear
close
clc
% Create variables
a = "Hello World";
b = "Today is Friday";
c = "I am happy";
% Define to filenames
varsFile = "workspace.csv";
% Convert variables to tables
dataTable = table(a, b, c);
% Write the tables to their respective files
writetable(dataTable, varsFile);
But this is easy if you have a few variables like the example I have above. What if I have many many variables. How can I do the task without calling table() and having to code every variable name? Suppose these are my variables:
a="a1"
b="a2"
c="a3"
d="a4"
e="a5"
f="a6"
g="a7"
h="a8"
i="a9"
j="a10"
k="a11"
l="a12"
m="a13"
n="a14"
o="a15"
p="a16"
q="a17"
r="a18"
s="a19"
t="a20"
u="a21"
v="a22"
w="a23"
x="a24"
y="a25"
z="a26"
As you can see, calling every variable is impratical. By the way, all my variables are strings.

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 9 月 24 日
  1 件のコメント
Missael Hernandez
Missael Hernandez 2021 年 9 月 24 日
My issue would then be to go from Excel to Matlab workspace without calling every single variable.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by