How can I obtain new coordinates of elements in strings array?
1 回表示 (過去 30 日間)
古いコメントを表示
I have an input like: A = ["e2_u3", "e4_u1", "e3_u2", "e_3_u1", "e2_u2", "e1_u1"]
and I want to create: M(i,j) = ["e1_u1" "e1_u2" "e1_u3"... "e1_uj" ;...;"ei_u1"..."ei_uj"].
In the case that the element exists in A, I want it to appear in M, and then I want to be able to say what was it's position in A.
Example:
txt= ["e2_u3", "e4_u1", "e3_u2", "e_3_u1", "e2_u2", "e1_u1"];
e = 4; u = 4;
order = strings(e,u);
for i=1:e
for m=1:u
if ismember(sprintf('e%d_u%d',i,m),txt)
order(i,m) = sprintf('e%d_u%d', i,m);
else
order(i,m)= 'Nan';
end
end
end
Now, I don't know how to tell the coordinate change from 'txt' to 'order'.
0 件のコメント
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!