How do I calculate percentage or frequency and display it on a bar plot?
11 次查看(过去 30 天)
显示 更早的评论
Hello I have an excel file with 48 land types and a image.tif of a country, and I want to calculate the Frequency (how many times each land type of the excel appear on the tif.iamge), and also the percentage of Frequency which is: Percentage=(Frequency/Total Frequency)*100.
I have calculated the frequency but does anyone know how to calculate the rate?? I tried
total = sum(frequency);
rate=(frequency/total):100;
It gives me results 48 times, as many times as my land types. How do I correct that?
Also I have to make a bar plot for the percentage results using colorbar.
Any ideas?
0 个评论
回答(2 个)
the cyclist
2020-7-3
Because you have the typo
rate=(frequency/total):100;
instead of
rate=(frequency/total)*100;
3 个评论
the cyclist
2020-7-3
It's not really possible to help debug plotting code that you don't show us. Can you upload the files needed for us to reproduce the error you are seeing?
the cyclist
2020-7-3
I also notice you keep saying "colorbar". If you are really trying to use the colorbar command to make a chart, you should be using bar instead.
Steven Lord
2020-7-3
Use histogram with 'probability' as the value for the 'Normalization' option.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!