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

You can use readtable and plot / bar functions. You could add excel data example and what you have written meanwhile to achieve this question.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sudhakar Shinde
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

Hi, thank you for your reply, however my table has many locations (up to hundreds), and all locations with hundreds of value1 and value2, is there a short cut? And I would like to link it with location=input('location=') where it just plots the location I input. Thank you so much!
If you could add your example data excel sheet, you may get more proper way.
HI, this is it, would like to plot days_tracked against total case but only the country I input
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.
Thank you!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

질문:

2020년 10월 27일

댓글:

2020년 10월 28일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by