how to plot percentage on y axis
3 ビュー (過去 30 日間)
古いコメントを表示
sir,i want to plot a variable 'L 'which is for life time of mobile nodes.i am getting the 'L' result numerically but its not showing on the graph.i want to plot it in both normal graph form and histogram form.i need the graph in percentage form i mean the y-axis should show the result in percentage and x-axis must show a fixed time .that means i m not taking any variable for expressing time.i found some expression from internet like below.but i m not getting exactly how to write the proper command.
hist(L); h=gca; labels=get(h,'yticklabel'); % get the y axis labels labels_modif=[num2str(100*str2num(labels)) ones(length(labels),1)*'%'] set(h,'yticklabel',labels_modif);
its only showing the y-axis labeling as percentage but not the exact result. pllzz help me sir.its urgent. Expecting a favorable reply. Thanking u SUCHI.
0 件のコメント
回答 (1 件)
Oleg Komarov
2011 年 5 月 15 日
Here's an example of how to set % values for the Y axis:ù
% Example input
L = 0:.1:1;
% Plot
plot(1:numel(L),L);
% Create labels
labels = reshape(sprintf('%5.1f%%',L*100),6,[]).';
% Adjust labels on plot
set(gca,'yticklabel',labels)
2 件のコメント
Oleg Komarov
2011 年 5 月 16 日
Well, if you don't give me example inputs for k, N, M, lij and xij my cristal ball surely won't help.
To get percentages from a number say maxA = 10 drawn from an array A = [10 2 5 6];
L = maxA/sum(A)*100;
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!