"Steven Lord" <slord@mathworks.com> wrote in message <hcesri$1al$1@fred.mathworks.com>...
>
> "Zeph Davies" <maylab@zephmail.co.uk> wrote in message
> news:hceqj2$amu$1@fred.mathworks.com...
> > Hi
> >
> > I have a surface I'm plotting using a n by m matrix filled with data from
> > a similar matrix in a text file.
> >
> > Currently the axis values are x=1:n, y=1:m and z is the minimum to maximum
> > matrix value.
> >
> > However i would like the axis to read an arbitrary range rather that 1:n,
> > for example, 200 to 2500 in steps of 100, or 20 to 10 (ie reversed),
> > without changing the surface, only the axis values.
> >
> > Changing the limits only changes where you look, pushing the graph out of
> > bounds.
> >
> > How do i go about achieving this?
>
> Two options off the top of my head:
>
> 1) Call SURF with three inputs (X, Y, and Z) instead of just one (Z)  as
> the documentation says, if you call it with just Z it uses 1:size(Z, 2) for
> the X coordinates and 1:size(Z, 1) for the Y coordinates.
>
> 2) Use the SET function to change the XTickLabel and YTickLabel properties
> of the axes. For your reversed limits, the XDir and YDir properties may
> also be useful. You will need the handle to the axes to do this; either
> calling AXES with an output argument before creating your surface plot or
> using GCA should do the trick.
>
> 
> Steve Lord
> slord@mathworks.com
> comp.softsys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
>
Finally got it, thank you!
See Below:
% Read First Line
[xmin xmax xstep ymin ymax ystep] = textread(FileName, '', 1, 'delimiter', '\t')
% Read Following Matrix
Z = textread(FileName, '', 1, 'headerlines', 1, 'delimiter', '\t');
for i = 0:(xmaxxmin)/xstep
X(i+1) = xmin+i*xstep;
end
for i = 0:(ymaxymin)/ystep
Y(i+1) = ymin+i*ystep;
end
% Plot Graph
surf(X,Y,Z);
Works great. However i had another error where i had "training tabs" at the end of each line of the matrix in the file. Solved with a if statement to not print a tab if last value.
Thank you again!
