How to define LineSpec in one variable?
46 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I would like to specify the line properties in one variable. For example, the code
plot([1,2],[1,2],'Color','black','LineWidth',2);
should be replaced by a code of the form (which produces an error):
LineSpec = {'Color','black','LineWidth',2};
plot([1,2],[1,2],LineSpec);
Thanks for any help!
plot([1,2],[1,2],'Color','black','LineWidth',2);
0 个评论
采纳的回答
Walter Roberson
2020-12-7
LineSpec = {'Color','black','LineWidth',2};
plot([1,2],[1,2],LineSpec{:});
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!