a problem about sprintf, array and concetnation
古いコメントを表示
i need a hope about this code, there's a mistake but i just can't figured it out..
i need the result:
out2=
[SemenPadang vs persiwa, SemenPadang vs persipura, PSPS vs ... SemenPadang, bye, Persisam vs semen padang;
PSPS vs Persipura, PSPS vs Persiwa, PSPS vs SemenPadang, bye, ...
BontangFc vs PSPS ]
teams = {'SemenPadang','PSPS','Sriwijaya','Persija','PelitaJaya','Persib','Persijap','Persibo','Arema','Persema','Persela','Deltras','Persiba','PSM','BontangFC','Persisam','Persiwa','Persipura'};
out2 =
[17 18 -2 0 -3 -4 5 6 -7 -8 9 10 -11 -12 13 14 -15 -16;
18 17 1 0 -4 -3 6 5 -8 -7 10 9 -12 -11 14 13 -16 -15 ]
ab = cat(2, teams, teams);
[brs, klm]= size(out2);
for b2= 1:brs
for k2= 1:klm
if out2(b2, k2) > 0
out2(b2, k2)= sprintf('%s vs %s\n', ab{b2}, ab{abs(out2(b2, k2))}); % when out2 is positive,
elseif out2(b2, k2) < 0
out2(b2, k2)= sprintf('%s vs %s\n', ab{abs(out2(b2, k2))}, ab{b2}); % it work's on single elements
else
out2(b2, k2)= sprintf('bye');
end
end
end
thx for attention and guidance..
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!