How can i make array with strings ?
Mostrar comentarios más antiguos
I need to make a array with strings. For exmaple I have tried this.
for i =1:100
for j =1:200
D(i,j) = sprintf('z_prop(%d,%d,hbsigmci)=%.4f;',i,j,normrnd(0,1));
end
end
I am getting error in assignment. Provide solution to error or Alternate way.
Thaks.
2 comentarios
Rik
el 6 de Feb. de 2020
What do you want to with this? It looks like you are preparing something with eval, which I would strongly discourage.
Also, do you want the result to be of the string class or the char class?
This looks like the start of some slow, complex, obfscuated, buggy code:
'z_prop(%d,%d,hbsigmci)=%.4f;'
What are you planning on doing with that character vector? Why not just assign that value directly?:
z_prop(i,j,hbsigmci) = normrnd(0,1);
Respuesta aceptada
Más respuestas (1)
In string related operations use cell array data type as
D = cell(100, 200);
for i =1:100
for j =1:200
D{i, j} = sprintf('z_prop(%d,%d,hbsigmci)=%.4f;',i,j,normrnd(0,1));
end
end
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!