02.03.2016 Views

MATLAB by rudra pratap

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

204 Graphics<br />

% SURFINTERP : script file to generate an interpolated surface<br />

% Given vectors x, y, and z, generate data matrix Zi from<br />

% interpolat ion to fit a surface through the data<br />

% -----------------------------------------------------------<br />

XV 2*rand(1, 100)-1;<br />

yv 2*rand(1, 100)-1;<br />

zv 3./(1 + xv .-2 + yv .-2) ;<br />

scatter3(xv,yv,zv)<br />

%<br />

%<br />

%<br />

%<br />

this is the given x<br />

this is the given y<br />

this is the given z<br />

show data as stem plot<br />

xi linspace (-1,1,30) ;<br />

yi xi';<br />

%<br />

%<br />

%<br />

create uniformly spaced xi<br />

create uniformly spaced yi<br />

note that yi is a column<br />

[Xi , Yi , Zi] griddata(xv,yv,zv,xi,yi,'v4');<br />

% interpolate surface using<br />

% v4 (<strong>MATLAB</strong> 4 griddata) method<br />

surf (Xi ,Yi,Zi)<br />

% plot the interpolated surface<br />

The interpolated surface is shown in Fig. 6.11.<br />

3<br />

2.5<br />

2<br />

1.5<br />

0.5<br />

1<br />

·1 ·1<br />

Figure 6.11: The interpolated surface.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!