num2str in legend
古いコメントを表示
I want to use num2str in title of a plot:
the problem is i need to make 8 in term wo_f8 dynamic as well as using num2str.(e.g I need to have wo_f20 in another run)
how can I do that?
any help is appreciated.
title({'f=' num2str(wo_f8)})
4 件のコメント
David Goodmanson
2020 年 8 月 29 日
編集済み: David Goodmanson
2020 年 8 月 30 日
Hello H-M
The most viable and useful solution is to not use dynamic variables in the first place. If you create wo_f as a vector with components, then you will be able to use wo_f(8), wo_f(20) etc, and, for example, wo_f(k) for the kth plot if that is what is wanted. It might take some work to go back and redefine the dynamic variables, but it's time well spent because of how convenient it make things later on.
Adam Danz
2020 年 8 月 29 日
"the problem is i need to make 8 in term wo_f8 dynamic"
The goal isn't clear to me. The title of your question references legends and then the quesitons references titles. If wo_f8, wo_f9, wo_f10, ... wo_f20 are variables you created then the advice given above is what I would also recommend. If you didn't create these variables (i.e. you're loading them into Matlab), you could organize the data into a cell array or structure and then loop through the elements.
c = {wo_f8, wo_f9, wo_f10, . . ., wo_f20 }; % or matrix if the values are scalar
for i = 1:numel(c)
title(axisHandles(i), {'f=', num2str(c{i})});
end
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Vector Volume Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!