draw two curves in matlab

2 views (last 30 days)
Lilian Lilian
Lilian Lilian on 6 Mar 2022
Edited: HWIK on 6 Mar 2022
I want to draw two curves in matlab , using this code,
In this curve I want x=0, 25, 50,75, .... but not 0, 20, 40,60
help me plz
x=[0:25:200];
y1= [0.4 0.29 0.21 0.19 0.13 0.11 0.09 0.05 0.006];
y2= [0.45 0.27 0.231 0.202 0.12 0.13 0.11 0.062 0.0062];
plot(x,y1,x,y2)

Answers (1)

HWIK
HWIK on 6 Mar 2022
Try this:
x=[0:25:200];
y1= [0.4 0.29 0.21 0.19 0.13 0.11 0.09 0.05 0.006];
y2= [0.45 0.27 0.231 0.202 0.12 0.13 0.11 0.062 0.0062];
plot(x,y1,x,y2)
xticks(x)
  2 Comments
Lilian Lilian
Lilian Lilian on 6 Mar 2022
Undefined function or variable 'xticks'.
Error in dessiner (line 4)
xticks(x)
HWIK
HWIK on 6 Mar 2022
Edited: HWIK on 6 Mar 2022
Maybe you are using an older Matlab version, as it was introduced relatively recently, you can still do this though:
x=[0:25:200];
y1= [0.4 0.29 0.21 0.19 0.13 0.11 0.09 0.05 0.006];
y2= [0.45 0.27 0.231 0.202 0.12 0.13 0.11 0.062 0.0062];
plot(x,y1,x,y2)
set(gca,'XTick',x)

Sign in to comment.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!