How to convert a large set of variables in the MATLAB workspace into an Excel file?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponses (1)
Sulaymon Eshkabilov
le 24 Sep 2021
Here is a nice discussion thread and help documentation: https://www.mathworks.com/matlabcentral/answers/589042-how-to-write-all-variables-in-workspace-into-excel
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!