An error occurred while trying to modify linewidth

6 visualizzazioni (ultimi 30 giorni)
Hi all,
I have tried to modify the linewidth as follows:
plot(t,means(k,:)*10^13,color{c},linewidth(c)),
where color ={'b',':b','k',':k','r',':r'}; linewidth = [0.5,3,0.5,3,0.5,3];
This works correctly without linewidth but when linewidth is added I get an error: ??? Error using ==> plot Attempt to modify a property that is read-only. Object Name : line Property Name : 'BeingDeleted'.
Could someone please let me know what I am doing wrong, and how the linewidth can be modified?
Thanks, Maria

Risposta accettata

Stephen23
Stephen23 il 29 Set 2014
Modificato: Stephen23 il 29 Set 2014
The documentation for the plot command states that you can set the LineSpec immediately after X and Y value arrays, which is why this works in your loop:
plot(t,means(k,:)*10^13,color{c})
because color{c} defines a LineSpec value (in your case, a color). According to the documentation the LineSpec can be any of "line style, marker symbol, and colorstring". Notice that this list does not include line width.
If you read the only section of the documentation that mentions line widths, you will see that this occurs under the section titled "Name-Value Pair Arguments". Name-Value Pairs are often used in MATLAB to enter optional arguments for many functions. You can read more information in the plot documentation.
For the sake of completeness, this is an example that the plot documentation contains, which includes changing the line width:
x = -pi:pi/10:pi;
y = tan(sin(x)) - sin(tan(x));
figure
plot(x,y,'--gs',...
'LineWidth',2,...
'MarkerSize',10,...
'MarkerEdgeColor','b',...
'MarkerFaceColor',[0.5,0.5,0.5])

Più risposte (1)

Maria
Maria il 29 Set 2014
Many thanks for the answer!
-Maria

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by