help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Matlab surf() function


From: Ben Abbott
Subject: Re: Matlab surf() function
Date: Thu, 28 Oct 2010 10:30:57 +0800

On Oct 28, 2010, at 12:31 AM, OCuanachain, Oisin (Oisin) wrote:

> Hi,
>  
> This is strictly a Matlab question, but poeple on this list seem to be 
> knowledgable about Matlab and I presume the same behaviour would be observed 
> in the Octave surf() so here goes; I'm using the surf() function to plot a 
> matrix of data vs. two vectors (eg heigth (matrix) vs. length(vect), 
> width(vect)). My problem is that my data set is not complete, ie the height 
> matrix has a number of entries that are NaN. This generally okay as the 
> function still plots the data EXCEPT for the case where there are isolated 
> points eg a data value surrounded by 9 NaNs, as the surf function seems to 
> work by displaying 'tiles' with four data points in the matrix acting as a 
> vertix of each tile if a point is surrouned by NaNs then it is invisible. So 
> I am wondering if there is some porperty I can set in the surf function so 
> that it will plot markers at each of the vertices of the tiles instead of 
> just the tiles, in that way the isolated data points would also be visible. 
> Does anyone know if this is possible?
>  
> for example
>  
> x = 1:10
> y = 1:5
> z = ones(5,10);
> figure
> surf(x,y,z)
>  
> This plots a plane at amplitude 1 as intended.
>  
> BUT
>  
> x = 1:10
> y = 1:5
> z = [ones(5,3) ones(5,1)*NaN ones(5,1) ones(5,1)*NaN ones(5,4)];
> figure
> surf(x,y,z)
>  
> Here the central line of isolated ones are not visible,
>  
> Any ideas ?
>  
> Thanks,

To plot points or the surface you'll need x, y, & z coordinates. You have the 
x,y but not z (when it is equal to NaN).

I recommend you look at interp2, and griddata. Using these you should be able 
to replace the NaNs with values interpolated from the non-NaN coordinates.

Ben

p.s. If you are using Matlab and not Octave, please take your question to the 
Matlab newsgroup. If you are using Octave, Welcome ! ! !




reply via email to

[Prev in Thread] Current Thread [Next in Thread]