How Can I Assign variable Name?

70 visualizaciones (últimos 30 días)
Giorgi
Giorgi el 14 de En. de 2015
Editada: Stephen23 el 25 de Jun. de 2019
Hi guys, I have some kinds of a data, that is in the variable called as First, and each day I have to update that data, but I should not lost the last data with respective variable name, so when I update data I have to create new variable for this updated data. well it is easy when you are making it manually, but in my case it should create automatically and the name of new variables should be the date of updated day for example today is 1/14/2015 so if i updated today variable name should be 1/14/2015. Any ideas would be a great job for me.

Respuesta aceptada

Stephen23
Stephen23 el 7 de Jul. de 2016
Editada: Stephen23 el 25 de Jun. de 2019

Más respuestas (2)

Shoaibur Rahman
Shoaibur Rahman el 14 de En. de 2015
x = 1:5;
eval([datestr(date,'mmmm_dd_yyyy') '= x']);
x is stored in a new variable named based on today's date. If you run the above code today, then you will get:
January_14_2015 =
1 2 3 4 5
  1 comentario
Iain
Iain el 14 de En. de 2015
This tells you, roughly, how to do it. HOWEVER, DON'T do it that way. It is a BAD idea.
Do it this way instead
days_data{day_of_month,month_of_year,year_from_x} = y;
That will give you a cell array that is 31 x 12 x number of years where each element can be as much data as you need.

Iniciar sesión para comentar.


Yona
Yona el 14 de En. de 2015
Editada: Yona el 14 de En. de 2015
you can use eval function.but it not recommended. and you cannot use / in variable name and it cannot start with a number.
so call it d01142015 or something like this.
X=['tr' num2str(14)];
eval(X, 'sin(pi/2)')
another way is to create a cell matrix. the first column will contain the date and the second column will contain all the data for the day.

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by