How do I plot specific data from an export excel file?
显示 更早的评论
I have a excel file with data which contains category and value. For example: Canada---3---30, Canada---4---40, Italy---3---20
I would like to plot the data only for the country I want, I use 'location=input('location=')', and would like the graph to only show the data for the location I typed for my plot(x,y).
How should I do that? Thank you.
1 个评论
Sudhakar Shinde
2020-10-27
回答(1 个)
Sudhakar Shinde
2020-10-27
Example:

Then you need plot of Value1 vs Value2 of country 'Canada' :
table=readtable('test1.xlsx');
Data= contains((table.Country),'Canada');
plot(table.Value1(Data),table.Value2(Data);)
6 个评论
Wong En Xin
2020-10-27
Sudhakar Shinde
2020-10-27
If you could add your example data excel sheet, you may get more proper way.
Wong En Xin
2020-10-28
Wong En Xin
2020-10-28
Sudhakar Shinde
2020-10-28
编辑:Sudhakar Shinde
2020-10-28
country = input('Input Country: ','s');
Data= contains((table.location),country); %Filter the data with location input
plot(table.days_tracked(Data),table.total_cases(Data)); %Plot days_tracked vs total_cases
% for input location
Above code lines will serve ur purpose.
Wong En Xin
2020-10-28
类别
在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
