Error: In an assignment A(:) = B, the number of elements in A and B must be the same.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
ely may
el 10 de Dic. de 2015
Respondida: the cyclist
el 10 de Dic. de 2015
Problem: TrajSimilarity is a struct of k elements, I want to put all the value of TrajSimilarity(1,k).aLongestString in a vector/array A. I try using this code but it generate error, can you help me to solve the problem?
Code:
for k=1:14
A(k)=TrajSimilarity(1,k).aLongestString;
end
Error:
In an assignment A(:) = B, the number of elements in A and B must
be the same
0 comentarios
Respuesta aceptada
the cyclist
el 10 de Dic. de 2015
I assume that A is either not initialized, or it is initialized as a numeric array. An element of a numeric array can only store one numeric value.
You might be able to use a cell array, which can store values of mixed types. In that case your syntax might be
A = cell(14,1);
for k=1:14
A{k}=TrajSimilarity(1,k).aLongestString;
end
Notice the use of {} instead of () to access the contents of each cell.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!