About HPC Systems Software User Guides Education Partners

  / gears / hpc / education / tutorials / matlab / linux


Introduction

Definition

Example 01

Example 02

Example 03

Example 04

Example 05

Example 06

Example 07

Example 08

Example 09

Example 10

Example 11

Example 12

Example 13

Example 14

Example 15

Example 16

Example 17

Example 18

References

Example 16

interp2( , , , , , )


GIVEN: (x,y,z) data file

REQUIRED: Interpolate z

SOLUTION: Generate example16.data

Enter your data as follows:
0.0 100 99 100 99 100 99 99 99 100;
0.5 100 99 99 99 100 99 100 99 99;
1.0 99 99 98 98 100 99 100 100 100;
1.5 100 98 97 97 99 100 100 100 99;
2.0 101 100 98 98 100 102 103 100 100;
2.5 102 103 101 100 102 106 104 101 100;
3.0 99 102 100 100 103 108 106 101 99;
3.5 97 99 100 100 102 105 103 101 100;
4.0 100 102 103 101 102 103 102 100 99;
4.5 100 102 103 102 101 101 100 99 99;
5.0 100 100 101 101 100 100 100 99 99;
5.5 100 100 100 100 100 99 99 99 99;
6.0 100 100 100 99 99 100 99 100 99;
load Example16.data
x=Example16(1:9,1);
y=Example16(:,1);
z=Example16(1:13,2:10);
mesh(x,y,z)
z_linear=interp2(x,y,z,2.2,3.3,'linear')
z_cubic=interp2(x,y,z,2.2,3.3,'cubic')
z_nearest=interp2(x,y,z,2.2,3.3,'nearest')
fid = fopen('example16.output','w');
fprintf(fid,'2-Dimensional Interpolation\n\n');
fprintf(fid,'%8.4f %8.4f %8.4f\n',z_linear,z_cubic,z_nearest);
status = fclose(fid);

figure
surf(x,y,z)
axis off
m=moviein(15);
for i=1:15
view(-37.5+24*(i-1),30)

m(:,i)=getframe;

end

Example

Homework:

Interpolate over a wider range


Please send questions or suggestions about this web page to beatnic@aset.psu.edu

ASET | ITS | Penn State