Prev: Java Exception Object
Next: fzero
From: James Young on 17 Mar 2010 16:46 Hi Folks Heres the scenario I have 3 variables: 1. Time (x axis) 2. Acc (y axis left) 3. Signal (y axis right) I have used plotyy, but I need to have 2 scales on the y axis and th right hand side one needs to be offset from th left. The left axis is -10 to 10, and the right hand axis is -0.1 to 5. I also want to label both y axes. Can anyone help. If so, please keep it simple as I am not a matlab guru lol. Thanks folks James
From: Paul Mennen on 18 Mar 2010 06:23 "James Young" wrote" > I have 3 variables: > 1. Time (x axis) > 2. Acc (y axis left) > 3. Signal (y axis right) > > I have used plotyy, but I need to have 2 scales on the y axis and th right hand side one needs to be offset from th left. > The left axis is -10 to 10, and the right hand axis is -0.1 to 5. > I also want to label both y axes. Can anyone help. If so, please keep it simple as I am not a matlab guru lol. > James Hi James. plotyy is slightly cryptic partly because to do anything meaningful you almost always have to use several auxilliary functions (as in your case). They are simple, but since they are not documented in one place many users are at a loss (judging from the large number of plotyy questions here. Your particular problem is pretty simple and can be done with just 3 lines (10 commands): a = plotyy(t,Acc,t,Signal); axes(a(1)); ylabel('Acc'); ylim([-10 10]); % set up left axis axes(a(2)); ylabel('Signal'); ylim([-.1 5]); % set up right axis An alternative interface to the matlab graphics for plotting 2D graphs is called "plt" and is available at the file exchange. The equivalent of the above 10 commands using plt would be: plt(t,[Acc; Signal],'ylim',{[-10 10] [-.1 5]},'ylabel',{'Acc' 'Signal'}); That's assuming Acc and Signal are row vectors. (If they are column vectors, simply remove the semicolon after Acc). Perhaps the most important advantage of plt is the documentation. Since nearly everything is done using optional parameters to the plt call, all the options are documented in one easy to search help file (with many examples). plt also stands out for its cursoring, zooming, and panning features. The more traces you need on a single graph, the more you will appreciate the logic and utility of the plt calling sequence over the matlab's traditional calls to plot, plotyy, and auxilliary functions. ~Paul
|
Pages: 1 Prev: Java Exception Object Next: fzero |