How do i assign the number(variable) to the name of variable?
    26 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    JaeSung Choi
 el 26 de En. de 2022
  
    
    
    
    
    Editada: Image Analyst
      
      
 el 26 de En. de 2022
            Hi, guys.
I want to make variables using numbers like this.
This doesn't work. But I'm sure that you can understand what I want to do in this code.:
N = 100; 
['data_N' num2str(N) ''] = N;
As a reseult, I want to get new variable 'data_N100'  with number 100.
I couldn't find some clear method, so I just wanna know evenif such work can't be done or not.
Thanks in advance!
0 comentarios
Respuesta aceptada
  Image Analyst
      
      
 el 26 de En. de 2022
        
      Editada: Image Analyst
      
      
 el 26 de En. de 2022
  
      You can simply do this
data_N100 = 100;
There is no prohibition of having numbers in the variable names.
Hopefully you don't want to do the horrible idea of dynamically naming variables, like so many beginners, because then it would be difficult to refer to and use those variables later.  See the FAQ for why that is a really bad idea.
0 comentarios
Más respuestas (0)
Ver también
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!