필터 지우기
필터 지우기

An error occurred while trying to modify linewidth

조회 수: 5 (최근 30일)
Maria
Maria 2014년 9월 29일
편집: Stephen23 2014년 9월 29일
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

채택된 답변

Stephen23
Stephen23 2014년 9월 29일
편집: Stephen23 2014년 9월 29일
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])

추가 답변 (1개)

Maria
Maria 2014년 9월 29일
Many thanks for the answer!
-Maria

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by