![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/272142/image.png)
How to plot fixed value for a number of ranges splited by a fixed step size in MATLAB?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Heya :)
am 17 Feb. 2020
Kommentiert: Heya :)
am 29 Feb. 2020
How to plot the figure in the image given below?![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/272138/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/272138/image.jpeg)
0 Kommentare
Akzeptierte Antwort
Giuseppe Inghilterra
am 17 Feb. 2020
Hi,
you can obtain your plot by using 'bar' matlab function (reference: https://www.mathworks.com/help/matlab/ref/bar.html).
For example if you run the following lines:
x = -1.5:0.1:1.5;
y = zeros(1,31);
y(10) = 0.8;
y(15) = 0.6;
bar(x,y,0)
you obtain the following plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/272142/image.png)
The 3rd input argument of bar function specify the width of each bar. In this case it is set to 0 in order to obtain your plot.
Then you can control label of x-axis and y-axis by using xlabel and ylabel function (example: xlabel('Coefficient value'), ylabel('Distribution') and set axes limits by using xlim, ylim functions.
4 Kommentare
Giuseppe Inghilterra
am 18 Feb. 2020
y(10) is just an example. You fill x and y with your data.
If you see reference link for bar MATLAB function you can find interesting example where you can customize bar plot. Ex: you can specify facecolor, edgecolor by giving RGB values.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!