|
On 6/8/2012 10:04 PM, Samuel wrote:
> Hello,
> I'm new to matlab and I'm trying to reverse the y-values on multiple
> files without success. Here's what I'm trying to do right now:
> ------------------------------------------------------------------------------------------------------------------------
>
> function i2m_reverseyaxis
> %This function will reverse the y-axis of the trial_x and trial_y
> %Select a folder containing zoo files
> fld = uigetfolder;
> cd(fld);
>
> if strcmp(computer,'PCWIN64')
> fl = engine('path',fld,'extension','zoo','sub','yes');
> else
> fl = engine('path',fld,'extension','zoo');
> end
Is engine() something like dir()???
> for i= 1:length(fl)
> fname = fl{i};
> t = load(fname,'-mat');
> data = t.data;
> if ~isempty(strfind(fname,'_x_'))
> set(gca,'yDir','reverse');
> elseif ~isempty(strfind(fname,'_y_'))
> set(gca,'yDir','reverse');
> else
> disp('nothing')
> end
> % save all the modifications
> save (fname,'data');
> end
...
> Basically, my values on the y-axis are from 180 to -180 and I want to
> reverse the y-values (to get a mirror of my plot). Could anyone help me
> please. Thank you in advance for your help.
I don't see any plot() commands for gca() to reference.
I don't think you need the isempty() in the if clauses, but it doesn't
hurt anything.
What seems to be not working? Looks like as long as your file names are
correct and match the naming convention you're testing for it ought to
swap the axis direction.
It isn't going to have any effect on the data on disk, however, only on
the plot as shown.
If you really intend to reverse the y data storage order, then you don't
need to fiddle w/ the plot axis direction, just do
fliplr() or flipud() on the y-vector before plotting.
--
|