Plotting different generations of performance
显示 更早的评论
Hello,
I would like to plot a graph where on the y axis the performance is shown and on the x axis the steps 1 to 100 repeat themselves. Instead of all graphs starting at the origin I would prefer if the first bundle of graphs is shown between 1 and 100 the second from 101 to 200 (ideally shown again as 1:25 etc etc ). Something like this: .1----100.1----100.1----100. where each . represents one generation and the origin for one bundle of graphs.
Could somebody be so kind and give me an idea on how to solve this?
cheers
回答(1 个)
Mandeep Singh
2018-5-21
From what I have understood from the question is that you want different bundles of graphs with a single Y-axis and single X-axis. But the X-axis should vary from 1-100 i.e. for the range 101-200 it should plot the next bundle of graph in the range 1-100.
Refer to the following snippet of code for the desired result. The code assumes that the function remains constant over different generations. You can make the changes to the code according to your requirements.
x = 1:100; % Assumed length of each period
n = 5; % No. of periods
f = x.^2; % Arbitrary function
ticks = 0:100:200*n+100;
for i = 0:2:2*n-1
xnew = x+100*i;
plot(xnew,f);
hold on;
end
str = num2str([1;100]);
string = repmat(str,2*n,1);
xticks(ticks);
xticklabels(string);
类别
在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!