From: SS C on 10 Aug 2010 16:57 I have two vectors a and b and I want to plot(a,b). However, the vector a has irregularly spaced values such as a = [5000,1, 30,2000]. I want to see plot([1:length(b)],b) but overlaid with the values in vector a for the labeling of the x axis. How can I do so? (i.e. I want to ignore the values of a, but I want to see in them in the labels, something like a categorical plot). Thanks!
From: Wayne King on 10 Aug 2010 17:12 "SS C" <sschiang8(a)gmail.com> wrote in message <i3sef0$m49$1(a)fred.mathworks.com>... > I have two vectors a and b and I want to plot(a,b). However, the vector a has irregularly spaced values such as a = [5000,1, 30,2000]. I want to see plot([1:length(b)],b) but overlaid with the values in vector a for the labeling of the x axis. How can I do so? (i.e. I want to ignore the values of a, but I want to see in them in the labels, something like a categorical plot). Thanks! Hi, b = randn(4,1); plot(b) set(gca,'xtick',1:length(b)) set(gca,'xticklabel',{'5000','1', '30','2000'}) Hope that helps, Wayne
From: Ross W on 10 Aug 2010 17:19 "SS C" <sschiang8(a)gmail.com> wrote in message <i3sef0$m49$1(a)fred.mathworks.com>... > I have two vectors a and b and I want to plot(a,b). However, the vector a has irregularly spaced values such as a = [5000,1, 30,2000]. I want to see plot([1:length(b)],b) but overlaid with the values in vector a for the labeling of the x axis. How can I do so? (i.e. I want to ignore the values of a, but I want to see in them in the labels, something like a categorical plot). Thanks! Hi you can do this: plot(b) set(gca,'XTick',1:length(b)) set(gca,'XTickLabel',num2str(a(:))) If you want the 'a' label next to the data point instead, use the text function Ross
From: SS C on 10 Aug 2010 17:24 Thanks! it works well =) "Wayne King" <wmkingty(a)gmail.com> wrote in message <i3sfb6$i02$1(a)fred.mathworks.com>... > "SS C" <sschiang8(a)gmail.com> wrote in message <i3sef0$m49$1(a)fred.mathworks.com>... > > I have two vectors a and b and I want to plot(a,b). However, the vector a has irregularly spaced values such as a = [5000,1, 30,2000]. I want to see plot([1:length(b)],b) but overlaid with the values in vector a for the labeling of the x axis. How can I do so? (i.e. I want to ignore the values of a, but I want to see in them in the labels, something like a categorical plot). Thanks! > > Hi, > > b = randn(4,1); > plot(b) > set(gca,'xtick',1:length(b)) > set(gca,'xticklabel',{'5000','1', '30','2000'}) > > Hope that helps, > Wayne
|
Pages: 1 Prev: Using data structures in Simulink Next: How do I link many subplots in different ways? |