Increasing Line Thickness Using fplot

조회 수: 9 (최근 30일)
Baran Karakus
Baran Karakus 2017년 11월 13일
댓글: Karan Gill 2017년 11월 13일
I want to plot the graph of the function f(x) = e^{-x} - e^{-16x} over the interval [0, 4] and I want the line to be black.
When I run the following code:
f = @(x) (exp(-x) - exp(-16*x));
fplot(f, [0, 4], 'black'),
I obtain the graph I want. However, I want the curve to be thicker on the graph. I have tried to run the following code instead:
f = @(x) (exp(-x) - exp(-16*x));
fplot(f, [0, 4], 'black', 'LineWidth', 2),
but this only gives me errors. I've read the MATLAB documentation for the fplot function but cannot make sense of it.

답변 (1개)

Star Strider
Star Strider 2017년 11월 13일
You need to use the handle to the line object to set the width:
This works:
f = @(x) (exp(-x) - exp(-16*x));
HL = fplot(f, [0, 4], 'black');
set(HL, 'LineWidth',2)
  댓글 수: 1
Karan Gill
Karan Gill 2017년 11월 13일
Using dot notation is easier.
f = @(x) (exp(-x) - exp(-16*x));
fh = fplot(f, [0 4], 'black');
fh.LineWidth = 2;
You can also easily set the color
fh.Color = 'green';

댓글을 달려면 로그인하십시오.

카테고리

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