MATLAB Answers

0

Graph with string variable

Asked by Zongo Amara Mohamed Isaac on 19 Jun 2019 at 12:27
Latest activity Commented on by Jan
on 24 Jun 2019 at 10:15
Hey guys,
I've just become very familiar with Matlab, but I'm having trouble building a graph:
on the X axis I would like to have the years and the values of the exports of manufactirial and food goods in order.
I don't know the code to use
thanking you in advance
attached my file

  0 Comments

Sign in to comment.

3 Answers

Answer by Zongo Amara Mohamed Isaac on 19 Jun 2019 at 22:33
 Accepted Answer

Thank you so much..it works...

  1 Comment

Jan
on 24 Jun 2019 at 10:15
Please post comments to an answer in the section for comments to an answer and select the answer, which solves the problem as accepted answer, not your comment. Then the readers knwo, which solution is working.

Sign in to comment.


Answer by Jan
on 19 Jun 2019 at 13:02

You did not even make an attempt?
data = readmatrix('data.xlsx');
plot(data(:, 1), data(:, 2), 'r', ...
data(:, 1), data(:, 3), 'b');

  0 Comments

Sign in to comment.


Answer by Star Strider
on 19 Jun 2019 at 13:10

Try this:
[D,S] = xlsread('data.xlsx');
Years = str2double(S(2:end,1));
figure
plot(Years, D)
grid
legend(S(1,2:3))
producing:
Graph with string variable - 2019 06 19.png

  1 Comment

Star Strider
on 19 Jun 2019 at 23:48
@Zongo Amara Mohamed Isaac —
If my Answer helped you solve your problem, please Accept it!

Sign in to comment.