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:
Curve

Subject: Curve

From: Niall Heavey

Date: 30 Jun, 2010 14:42:04

Message: 1 of 4

Hi all, I am looking to plot a straight forward curve.
I thought it would be simple enough to do but I can't find anything to help me so far.

Basically I want a curve from point 1 to point 3 that goes through point 2.

Sounds simple enough but does anyone know a function available for it?

Thanks in advance.

Subject: Curve

From: John D'Errico

Date: 30 Jun, 2010 15:27:04

Message: 2 of 4

"Niall Heavey" <REMOVEniallALLheaveyCAPLOCKS@gmail.com> wrote in message <i0fl3s$aqc$1@fred.mathworks.com>...
> Hi all, I am looking to plot a straight forward curve.
> I thought it would be simple enough to do but I can't find anything to help me so far.
>
> Basically I want a curve from point 1 to point 3 that goes through point 2.
>
> Sounds simple enough but does anyone know a function available for it?
>
> Thanks in advance.

There are infinitely many such curves.

The simplest is a piecewise linear curve, i.e., connect the dots.
Plot can do it for you.

If you want a better answer than that, you need to tell us, is
this in two dimensions? Or 3 or more? Must the curve be smooth?
Is this a single valued relationship, or does the curve wrap around?

John

Subject: Curve

From: Roger Stafford

Date: 30 Jun, 2010 15:43:04

Message: 3 of 4

"Niall Heavey" <REMOVEniallALLheaveyCAPLOCKS@gmail.com> wrote in message <i0fl3s$aqc$1@fred.mathworks.com>...
> Hi all, I am looking to plot a straight forward curve.
> I thought it would be simple enough to do but I can't find anything to help me so far.
>
> Basically I want a curve from point 1 to point 3 that goes through point 2.
>
> Sounds simple enough but does anyone know a function available for it?
>
> Thanks in advance.
- - - - - - -
  As John says, there are infinitely many possible ways. For example, if you want a second order polynomial in 2-space - a quadratic function - to go through the three points, let the points be (x1,y1), (x2,y2), and (x3,y3). If the polynomial is expressed in the form

 y = c2*x^2 + c1*x + c0

the three coefficients can be determined from

 c = [x.^2,x,ones(3,1)]\y;

where x = [x1;x2;x3], y = [y1;y2;y3], and c = [c2;c1;c0].

Roger Stafford

Subject: Curve

From: Niall Heavey

Date: 30 Jun, 2010 15:54:04

Message: 4 of 4

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <i0fno8$60j$1@fred.mathworks.com>...
> "Niall Heavey" <REMOVEniallALLheaveyCAPLOCKS@gmail.com> wrote in message <i0fl3s$aqc$1@fred.mathworks.com>...
> > Hi all, I am looking to plot a straight forward curve.
> > I thought it would be simple enough to do but I can't find anything to help me so far.
> >
> > Basically I want a curve from point 1 to point 3 that goes through point 2.
> >
> > Sounds simple enough but does anyone know a function available for it?
> >
> > Thanks in advance.
>
> There are infinitely many such curves.
>
> The simplest is a piecewise linear curve, i.e., connect the dots.
> Plot can do it for you.
>
> If you want a better answer than that, you need to tell us, is
> this in two dimensions? Or 3 or more? Must the curve be smooth?
> Is this a single valued relationship, or does the curve wrap around?
>
> John

Its two dimensions, it would be better if it is smooth.

I'd say the easiest way to explain it would be to send the code:

radius = 10;
plot(0,0,'b*')
hold on
i = 4;

for j = 1:i*2
    t = linspace(0,2*pi,(i*2)+1);
    t = linspace(-(t(2)/2),((2*pi)-(t(2)/2)),(i*2)+1);
    r = radius;
    A = r*cos(t);
    B = r*sin(t);
    plot(A(j),B(j),'b*')

% axis ([-25 25 -25 25])
% axis square
% % text(a(j),b(j),strcat(' User ',num2str(j)))
end

for j = 1:i
    t = linspace(0,2*pi,i+1);
    r = radius*2;
    a = r*cos(t);
    b = r*sin(t);
    plot(a(j),b(j),'g*')

    axis ([-25 25 -25 25])
    axis square
    text(a(j),b(j),strcat(' User ',num2str(j)))
end

So basically what i'm trying to do is create a link between the center point and user 1, this would be going through both point A(1),B(1) and A(2),B(2), then the link to user 2 form the center would go through A(3),B(3) and A(4),B(4) and so on.

Hope that makes more sense!

Thanks

Tags for 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