我有一些节点a,我想把数字按顺序从1改为4。并在下面的代码中将链接更改为link_new。你能帮我吗?
A= [23;
24;
27;
45];
link= [23 24;
24 27 ;
24 45;
27 45];
结果
A_new = [1;
2;
3;
4]
link_new =[1 2;
2 3;
2 4;
3 4]
A = [23; 24; 27; 45];
link = [23, 24; 24, 27; 24, 45; 27, 45];
A_new = A;
link_new = link;
for idx = 1:numel(A)
a = A(idx);
A_new(idx) = idx;
link_new(link_new == a) = idx;
end