How can i make array with strings ?
Ältere Kommentare anzeigen
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 Kommentare
Rik
am 6 Feb. 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);
Akzeptierte Antwort
Weitere Antworten (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
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!