MATLAB Answers

Plot 9 parameters for 29 country for 20 years in one curve

1 view (last 30 days)
Dear,
I want to plot using MATLAB, a curve or 3D plot for this database :
ALB 1996 -0,6215114
ALB 1997 -0,6254301
ALB 1998 -0,62933439
ALB 1999 -0,63335227
ALB 2000 -0,63735683
BGD 1996 2,13048473
BGD 1997 2,11153446
BGD 1998 2,07734031
BGD 1999 2,02275107
BGD 2000 1,95238739
So, I have 3 parameters: 1/ countries 2/ years 3/ values
In the example above i used only few data, but could you please find the total database attached (Excel File) I worked on 9 parameters, 29 countries, and 20 years, I want to obtain 9 plots, so for each parameter i have a plot.
Could you please help to resolve this issue ?

  0 Comments

Sign in to comment.

Accepted Answer

Sudheer Bhimireddy
Sudheer Bhimireddy on 8 Aug 2020
Edited: Sudheer Bhimireddy on 8 Aug 2020
You can try something like this:
% Read data from one sheet
data = readtable('base.xlsx','Sheet','Feuil6');
% Read a parameter
temp = data(:,5);
% Reshape the parameter
temp = reshape(temp.lnide,[29 22]);
% Get the country names and years
countries = unique(data.payscode);
countries = cell2mat(countries);
years = unique(data.Ann_e);
% Plot
h = bar3(temp);
ax = gca;
ax.XTick = 1:3:size(years);
ax.XTickLabel = years(1:3:end);
ax.YTick = 1:3:size(countries);
ax.YTickLabel = countries(1:3:end,:);
to get:
Alternate way is to use plot() with different linestyles and line colors. But that will look messy with 29x20 lines for each parameter.

  0 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by