Azzera filtri
Azzera filtri

How to define LineSpec in one variable?

22 visualizzazioni (ultimi 30 giorni)
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);

Risposta accettata

Walter Roberson
Walter Roberson il 7 Dic 2020
LineSpec = {'Color','black','LineWidth',2};
plot([1,2],[1,2],LineSpec{:});

Più risposte (0)

Categorie

Scopri di più su Animation in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by