Graph with string variable
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Zongo Amara Mohamed Isaac
2019-6-19
1 个评论
Jan
2019-6-24
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.
更多回答(2 个)
Jan
2019-6-19
You did not even make an attempt?
data = readmatrix('data.xlsx');
plot(data(:, 1), data(:, 2), 'r', ...
data(:, 1), data(:, 3), 'b');
0 个评论
Star Strider
2019-6-19
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](https://www.mathworks.com/matlabcentral/answers/uploaded_files/225500/Graph%20with%20string%20variable%20-%202019%2006%2019.png)
1 个评论
Star Strider
2019-6-19
@Zongo Amara Mohamed Isaac —
If my Answer helped you solve your problem, please Accept it!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Directed Graphs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!