MATLAB Answers

Mariana
0

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

Asked by Mariana
on 14 Nov 2019 at 9:25
Latest activity Answered by Athul Prakash on 21 Nov 2019 at 10:08
%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;
end
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

1 Answer

Answer by Athul Prakash on 21 Nov 2019 at 10:08

Dynamically changing variable names is not advised, I think you should try storing the data in multiple different tables.

  0 Comments

Sign in to comment.