Info
此问题已关闭。 请重新打开它进行编辑或回答。
How can I have the title on a graph change depending on whats in the graph?
1 次查看(过去 30 天)
显示 更早的评论
I have created 7 graphs, all of them are comparing different things, but the y axis is the same in all. I have a working for loop generating the graphs. I was wondering if I can add the title into the loop so it creates the title based on what is in the x axis of the plot. The code below plots them perfectly, I am just looking for a way to add a unique title to each.
for i = 1:numel(xcardata)
figure(i)
plot(xcardata{i}, ycardata, 'ob')
end
0 个评论
回答(1 个)
Star Strider
2020-11-7
Example —
x = 1:0.1:5;
for k = 1:5
y = x.^k;
figure
plot(x, y)
title(sprintf('y = x^{%d}',k))
end
.
2 个评论
Star Strider
2020-11-8
Choose the text you want in the title sprintf call, then use '%s' instead to write character vectors , i.e. words.
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!