using sprintf for floating point numbers
古いコメントを表示
optEnergyCost=[42 36 28.5 26 39.7 25 57047]
optEnergyCostString=sprintf('%g',optEnergyCost)
optEnergyCostString=strrep(optEnergyCostString,'42','Route_1');
optEnergyCostString=strrep(optEnergyCostString,'36','Route_1');
optEnergyCostString=strrep(optEnergyCostString,'28.5','Route_2');
optEnergyCostString=strrep(optEnergyCostString,'26','Route_2');
optEnergyCostString=strrep(optEnergyCostString,'39.7','Route_1');
optEnergyCostString=strrep(optEnergyCostString,'25','Route_1');
but results are
optEnergyCostString =
423628.52639.72557046.5 how to get this as optEnergyString= route1 route1 route2 route2 route1 route1 57047
3 件のコメント
Jan
2016 年 12 月 16 日
You are funny. How could we know what you find "correct". All we see is the code which does what the code does. But what do you want instead?
summyia qamar
2016 年 12 月 16 日
Image Analyst
2016 年 12 月 16 日
And I answered it there: http://www.mathworks.com/matlabcentral/answers/317037-replace-numbers-with-letters-in-a-vector-or-matrix#answer_247544 so your code will look normal.
By the way, for next time, read this http://www.mathworks.com/matlabcentral/answers/13205#answer_18099
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Desktop についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!