HOW to draw the type of graph in matlab

1 view (last 30 days)
juwon yeo
juwon yeo on 13 Mar 2019
Commented: Star Strider on 13 Mar 2019
f(x)=k (0<x<pi)
  1 Comment
Geoff Hayes
Geoff Hayes on 13 Mar 2019
juwon - is k a constant for all x? Is that the intent?

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 13 Mar 2019
Try this approach, using ‘logical indexing’:
k = 0.1;
f = @(x) k*((0 < x) & (x < pi));
x = linspace(-pi/2, 3*pi/2);
figure
plot(x, f(x))
grid
Experiment to get the result you want.
  1 Comment
Star Strider
Star Strider on 13 Mar 2019
If my Answer helped you solve your problem, please Accept it!

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!