Functions | |
function | interpimages (nm, typ) bury_output() |
if (strcmp(typ,"png")) set(0 | |
*endif | if (strcmp(typ,"txt")) image_as_txt(nm) |
plot (ti, yp, 'g', ti, interp1(t, y, ti, 'spline'), 'b',...ti, interpft(y, k), 'c', t, y, 'r+') | |
legend ('sin(4t+0.3) cos(3t-0.1)','spline','interpft','data') | |
print (cstrcat(nm,".", typ), cstrcat("-d", typ)) elseif(strcmp(nm | |
mesh (zi, yi, squeeze(vi(1,:,:))) | |
plot (ti, ys,'r-', ti, yp,'g-') | |
legend ('spline','pchip', 4) | |
plot (ti(2:end-1), ddys,'r *', ti(2:end-1), ddyp,'g+') | |
legend ('spline','pchip') | |
endfunction function | bury_output () f |
set (f,"visible","off") | |
endfunction function | image_as_txt (nm) fid |
fputs (fid,"\n") | |
fputs (fid,"+---------------------------------+\n") | |
fputs (fid,"| Image unavailable in text mode. |\n") | |
fclose (fid) | |
Variables | |
defaulttextfontname | |
elseif(strcmp(nm,"interpft")) t=0 | dt = t(2)-t(1) |
n = length (t) | |
k = 100 | |
ti = t(1) + [0 : k-1]*dt*n/k | |
y = sin (4*t + 0.3) .* cos (3*t - 0.1) | |
yp = sin (4*ti + 0.3) .* cos (3*ti - 0.1) | |
interpn | x = y = z = -1:1 |
f = @(x,y,z) x.^2 - y - z.^2 | |
v = meshgrid (x, y, z) f (xx,yy,zz) | |
xi = yi = zi = -1:0.1:1 | |
vi = ndgrid (xi, yi, zi) interpn(x, y, z, v, xxi, yyi, zzi, 'spline') | |
interpderiv1 | t = -2:2 |
dti = 0.025 | |
ys = interp1(t,y,ti,'spline') | |
ddys = diff(diff(interp1(t,y,ti,'spline'))./dti)./dti | |
ddyp = diff(diff(interp1(t,y,ti,'pchip'))./dti)./dti |
endfunction function bury_output | ( | ) |
fclose | ( | fid | ) |
fputs | ( | fid | , | |
"+---------------------------------+\n" | ||||
) |
fputs | ( | fid | , | |
"\n" | ||||
) |
if | ( | strcmp(typ,"png") | ) |
endfunction function image_as_txt | ( | nm | ) |
legend | ( | 'spline' | , | |
'pchip' | ||||
) |
legend | ( | 'spline' | , | |
'pchip' | , | |||
4 | ||||
) |
mesh | ( | zi | , | |
yi | , | |||
squeeze(vi(1,:,:)) | ||||
) |
plot | ( | ti | , | |
yp | , | |||
'g' | , | |||
ti | , | |||
interp1(t, y, ti, 'spline') | , | |||
'b' | , | |||
ti, | ||||
interpft(y, k) | , | |||
'c' | , | |||
t | , | |||
y | , | |||
'r+' | ||||
) |
( | cstrcat(nm,".", typ) | , | ||
cstrcat("-d", typ) | ||||
) |
set | ( | f | , | |
"visible" | , | |||
"off" | ||||
) |
dt = t(2)-t(1) |
dti = 0.025 |
test f = @(x,y,z) x.^2 - y - z.^2 |
k = 100 |
test n = length (t) |
else t = -2:2 |
v = meshgrid (x, y, z) f (xx,yy,zz) |
interpn x = y = z = -1:1 |
endif endfunction shared xi = yi = zi = -1:0.1:1 |
y = sin (4*t + 0.3) .* cos (3*t - 0.1) |