MATLAB Answers

Change the name of a table located in my workspace inside a for loop

6 views (last 30 days)
Mariana on 14 Nov 2019
Answered: Athul Prakash on 21 Nov 2019
%Data Folder Analysis
file = dir(fullfile('C:\Users\Desktop\data','*mat'));
num_files=sprintf('The following mat files are to be analyzed: %d',length(file));
%Amount of files analyzed
for i=1:1 %length(file)
current_file = sprintf('Data_set_%d.mat',i);
table_name= table (t,x,y,m)
new_name =sprintf('Table',i);
table_name = new_name;
I am trying this but it is not working if the new name that I want to assign is variable.
If I try:
a = table_name;
then the table is saved, but I want to change the name of "a" on evry iteration

Answers (1)

Athul Prakash
Athul Prakash on 21 Nov 2019
Dynamically changing variable names is not advised, I think you should try storing the data in multiple different tables.


Sign in to comment.