left and right sides have a different number of elements
    1 visualización (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Mohamed Salah
 el 9 de Mayo de 2020
  
    
    
    
    
    Comentada: Mohamed Salah
 el 9 de Mayo de 2020
            o=4;
m = ['c','d','c','f','e','c'];
oo=o.*ones(1,length(m));
q=zeros(1,length(m));
w=zeros(1,length(m));
for i=1:length(m)
    q(i)=strcat(m(i),num2str(oo(i))); %here is where the error happens
    w(i)=eval(q(i));
end
I know that eval function is not recommended but I'm trying something with my code and it doesn't have to do anything with the error (until now atleast)
0 comentarios
Respuesta aceptada
  Rik
      
      
 el 9 de Mayo de 2020
        I hesitate to even answer this question. The use of eval is a bad idea. Do not do that. eval can almost always be avoided and your code doesn't look like an exception.
The reason for this error is that you are trying to store multiple chars in a single position. You need to either use strings (use double quotes), or you need to adapt the indexing for q, or replace all occurrences of q(i) with q.
Más respuestas (0)
Ver también
Categorías
				Más información sobre Logical en Help Center y File Exchange.
			
	Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!