Filter löschen
Filter löschen

Change x axis increments

154 Ansichten (letzte 30 Tage)
Dobs
Dobs am 22 Nov. 2021
Beantwortet: Star Strider am 22 Nov. 2021
Hi,
I am trying to write the code for the plot in the attached image. This is what I have so far:
a = [0,10,20,30,50,80,130,210,340,550];
b = linspace (0, 50, 10);
figure;
plot(a, 50-b);
xlim([0 550]);
yticks([0 10 20 30 40 50]);
The graph needs to be a straight line. How can I achieve that? My second question is how do I set the x axis to look like the one in the attached image? Is there a way to "customize" it? I've tried the following:
a = [0,10,20,30,50,80,130,210,340,550];
b = linspace (0, 50, 10);
figure;
plot(a, 50-b);
xlim([0 550]);
xticks(a);
yticks([0 10 20 30 40 50]);
But that obviously hasn't worked. Is there a way to get the number to be evenly spaced? I also don't understand how I can get matlab to add two 10s to the x axis.
If anyone has any suggestion, I'd gretaly appreciate it!
Many thanks,
Dobs

Antworten (1)

Star Strider
Star Strider am 22 Nov. 2021
See Axes Properties, specifically XScale, YScale, ZScale.
.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by