Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
interpolation

Subject: interpolation

From: ssundar78@hotmail.com (sundar)

Date: 2 Oct, 2000 23:39:10

Message: 1 of 5

hi my problem is this
i know the value of an unknown funtion in 8 points on the
circumference of the circle
i need to know the value of the funtion in some 20 ppoints on the
circunference of the circle+the value of function at the centre of the
circle and its values along various lines joining the centre and
circunference of the circle
i am a beginner to matlab so iwould really be obliged to you if you
can send me a detailed answer with code if possible
bye
sundar

Subject: interpolation

From: Michael Robbins

Date: 3 Oct, 2000 12:40:25

Message: 2 of 5

Sounds more like geometry than interpolation. In fact, at first glance
you should need only 3 points to determine the circle.

--
Michael Robbins
Director, Primary Dealership
Canadian Imperial Bank of Commerce, World Markets
New York


Sent via Deja.com http://www.deja.com/
Before you buy.

Subject: interpolation

From: blunden@cc.umanitoba.ca (Peter Blunden)

Date: 3 Oct, 2000 15:52:14

Message: 3 of 5

Let me answer your question in 2 parts.

First, if you know the value of the function at 8 points on the
circumference of the circle, you can use interpolation by mapping the
circumference into a function of 1 variable, the polar angle theta.
Define 9 points theta_1, theta_2, theta_3 ... theta_8, theta_9
where theta_9 = theta_1 + 2*pi
Then interpolate (you choose the degree of the interpolating polynomial
... cubic?) to the polar angles of interest and transform back again.

The second part of your question concerns values of the function at
interior points. This is an ill-posed question. Knowing the value of a
function at a boundary isn't enough information to determine the
function away from the boundary. Think of the one-dimensional
analog ... given the value of a function at 2 points, all you can do
is draw a straight line between them (linear interpolation). But
there is no reason to have any faith in that procedure.

However, if that's what you have in mind, here is a suggestion.
Interpolate the values of the function at the 8 points onto a set of
equally spaced polar angles (these could be your 20 points). Then take
the mean of the function values at these points as the value at the
center of the circle. Now do linear interpolation from points on the
circumference to the center. Of course, your interpolated function
will have a discontinuous derivative at the center.


In <ur3k37u0czni@forum.mathforum.com> ssundar78@hotmail.com (sundar) writes:

>hi my problem is this
>i know the value of an unknown funtion in 8 points on the
>circumference of the circle
>i need to know the value of the funtion in some 20 ppoints on the
>circunference of the circle+the value of function at the centre of the
>circle and its values along various lines joining the centre and
>circunference of the circle
>i am a beginner to matlab so iwould really be obliged to you if you
>can send me a detailed answer with code if possible

Subject: interpolation

From: Benjamin P. Abbott

Date: 4 Oct, 2000 07:01:45

Message: 4 of 5

This is a multi-part message in MIME format.
--------------8869AF0ABC5E135EF14D616E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello Sundar,

If I understand your problem correctly, it should be possible to
solve it using a polynomial fit.

% start with the 8 points you know (I assume these #s are complex).
x8=[r1+j*q1 r2+j*q2 r3+j*q3 r4+j*q4 r5+j*q5 r6+j*q6 r7+j*q7 r8+j*q8];
f8=[u1+j*v1 u2+j*v2 u3+j*v3 u4+j*v4 u5+j*v5 u6+j*v6 u7+j*v7 u8+j*v8];
% fit a 7th order polynomial (a smaller order may also work)
p = polyfit(x8,f8,7);
% now you can evaluate the fit to your function at any point "x" using..
f = polyval(p,x);

Good luck, Ben

sundar wrote:

> hi my problem is this
> i know the value of an unknown funtion in 8 points on the
> circumference of the circle
> i need to know the value of the funtion in some 20 ppoints on the
> circunference of the circle+the value of function at the centre of the
> circle and its values along various lines joining the centre and
> circunference of the circle
> i am a beginner to matlab so iwould really be obliged to you if you
> can send me a detailed answer with code if possible
> bye
> sundar

--------------8869AF0ABC5E135EF14D616E
Content-Type: text/x-vcard; charset=us-ascii;
 name="bpabbott.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Benjamin P. Abbott
Content-Disposition: attachment;
 filename="bpabbott.vcf"

begin:vcard
n:Abbott;Benjamin
tel;home:(407) 660 1794
x-mozilla-html:FALSE
adr:;;;Orlando;FL;32810;USA
version:2.1
email;internet:bpabbott@ibm.net
fn:Ben Abbott
end:vcard

--------------8869AF0ABC5E135EF14D616E--

Subject: interpolation

From: blunden@cc.umanitoba.ca (Peter Blunden)

Date: 4 Oct, 2000 16:26:10

Message: 5 of 5

In <ur3k37u0czni@forum.mathforum.com> ssundar78@hotmail.com (sundar) writes:

>hi my problem is this
>i know the value of an unknown funtion in 8 points on the
>circumference of the circle
>i need to know the value of the funtion in some 20 ppoints on the
>circunference of the circle+the value of function at the centre of the
>circle and its values along various lines joining the centre and
>circunference of the circle
>i am a beginner to matlab so iwould really be obliged to you if you
>can send me a detailed answer with code if possible

Here is something that will do the job.

---------------------------------------
function [zmesh,xmesh,ymesh] = interpcirc(theta,z,nr,np,method);
%
% interpcirc.m
% Useage: [zz,xx,yy] = interpcirc(theta,z,nr,np,method)
%
% Interpolation of a function defined on the circumference of a circle of
% unit radius into the interior of the circle. The function is
% interpolated onto nr equally spaced radial points (including r=0) and np equally
% spaced polar angles. Default is cubic interpolation.
% Input: theta = set of polar angles at which z(theta) is defined.
% (theta does not have to be equally spaced or monotonically increasing)
% nr = number of radial points for the interpolated function
% np = number of polar angles for the interpolated function
% method = 'linear', 'cubic', or 'nearest' interpolation method (default 'cubic')
% Output: zmesh is the interpolated function defined on a Cartesian mesh
% defined by x and y, with dimension (nr,np+1)
% x and y are Cartesian mesh points along radial arms, with dimension (nr,np+1)
%
% Author: Peter Blunden (blunden@physics.umanitoba.ca) 2000
%
% Example:
% theta=rand(1,10)*2*pi;
% z=rand(1,10);
% interpcirc(theta,z,20,60);
%

if nargin<5
   method='cubic';
end
if ~ischar(method)
   method='cubic';
end

[theta,ind]=unique(sort(theta)); % make sure polar angles are monotonically increasing
if theta(end)>=2*pi | theta(1)<0
   error('polar angles must be in the range 0<= theta < 2*pi');
end
x=cos(theta); % find Cartesian points
y=sin(theta);
z=z(ind);
tt=[theta theta(1)+2*pi]; % wrap around to cover full angular range
zz=[z z(1)];
%ti=[0:np-1]*2*pi/np+tt(1); % np interpolated angles on circumference, no wraparound angle
ti=[0:np]*2*pi/np+tt(1); % np interpolated angles on circumference, plus wraparound angle
npolar=length(ti);
xi=cos(ti);
yi=sin(ti);
zi=interp1(tt,zz,ti,method); % interpolated function values on circumference

ri=[0:nr-1]/(nr-1);
xmesh=zeros(nr,npolar); % generate Cartesian mesh points within circle along radial arms
ymesh=xmesh;
for i=1:nr
   for j=1:npolar
      xmesh(i,j)=ri(i)*cos(ti(j));
      ymesh(i,j)=ri(i)*sin(ti(j));
   end
end
zmesh=griddata(xi,yi,zi,xmesh,ymesh,method);

if nargout==0
   mesh(xmesh,ymesh,zmesh); % plot interpolated surface
   hold on;
   plot3(x,y,z,'o'); % plot original data points as circles
   rotate3d; % click and rotate plot to view from different perspectives
end

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us