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

조회 수: 2 (최근 30일)
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 CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by