There may be variables in the program that have the same name as the strings in the 55 cells but what you have in the cells are simply strings so you can just reassign them to whatever you want.
Change variable name in mat.
Change variable names in a table.
Now whenever i am loading a new mat file i am changing the name of the variable 6 times in the program.
Share improve this answer follow answered nov 8 11 at 1 05.
Is there any other better way to do this than.
T load.
Defines a variable named array or assigns a new value to an existing variable with the name array which is an array consisting of the values 1 3 5 7 and 9 that is the array starts at 1 the initial value increments with each step from the previous value by 2 the increment value and stops once it reaches or to avoid exceeding 9 the terminator value.
You can then save the struct back out to the mat file with the struct flag.
Now i want to save values of mydata in mat file but i want to save the value under a variable name given via input function.
For mat files append adds new variables to the file or replaces the saved values of existing variables with values in the workspace.
In each cell is simply a string.
Ok i opened your mat file and it s simply a 1 row by 55 column cell array a row vector of cells.
A similar problem occurs if i load a file but for any reason have no possibility to read out the name of the variable stored in it.
What i am asking is how can i use the name of the mat file here lrww in the rest of the commands without having to write it manually.
Thanks for your answer but that is not what i was looking for.
Note that it is actually much easier to process a sequence of mat files if they contain exactly the same variable names because then these can be trivially imported into one non scalar structure and accessing using simple efficient indexing.
The load option with output argument then your variables become fields of that struct which allows you to rename them renaming variables themselves is not a fun task.
If you load the mat file into a struct i e.
This saves my data in data mat file but with variable name mydata.
You could then use struct2cell to trivially access the field contents and place these into one array numeric cell etc using basic matlab indexing.
Learn more about change variable names variable change matlab.
This method follows the general rule of thumb to avoid poofing variables into the workspace.