how to create dictionary of countries with respective name of langauge in matlab

One way to create a dictionary of countries with their respective language name is by using a MATLAB containers.Map object. Here's an example:

main.m
% define the dictionary
countryLanguage = containers.Map;

% populate the dictionary with key-value pairs
countryLanguage('USA') = 'English';
countryLanguage('China') = 'Mandarin';
countryLanguage('Japan') = 'Japanese';
countryLanguage('Germany') = 'German';
% and so on...

% retrieve the language name for a given country
languageName = countryLanguage('USA');
disp(languageName); % output: 'English'
403 chars
14 lines

You can add more countries and languages to the dictionary by adding more key-value pairs using the () notation. You can retrieve the value (i.e., the language name) associated with a key (i.e., the country name) using () notation with the key as the argument.

gistlibby LogSnag