How could you write a function that returns a histogram with axis labels and title
8 ビュー (過去 30 日間)
古いコメントを表示
Currently I have: which creates the graph with the axis and title labels but the data for the histogram doesn't show up on the histogram. pls help <3
function [a,b,c,d]= Histogram_Function(x)
a= hist(x);
b= title('asdasd');
c= xlabel('ban');
d=ylabel('anana');
end
0 件のコメント
回答 (1 件)
dpb
2018 年 10 月 4 日
hist when save the return value only returns the counts vector and, as you've discovered; doesn't actually draw the plot.
To continue to use hist you would have to do something like
function [cnts,cntrs,hLabels]= Histogram_Function(x)
[cnts,cntrs]=hist(x);
bar(cntrs,cnts)
hLabels(1)=title('asdasd');
hLabels(2)=xlabel('ban');
hLabels(3)=ylabel('anana');
end
NB1: USE MEANINGFUL VARIABLE NAMES!!! Makes very difficult to read and maintain code when there's no semblance of any relationship between the variable name and its purpose.
NB2: hist has been deprecated; strongly urge to consider using histogram instead unless you are forced to use a release prior to R2014b.
...
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Histograms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!