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:
curved lined on matlab plot

Subject: curved lined on matlab plot

From: chimi

Date: 26 Apr, 2013 00:25:13

Message: 1 of 8

Hello can anyone tell me how can i make plot lines look curved? i have some points and when i make a plot the lines are straight but i want curved lines. Is there a command to do this for me?
thank u

Subject: curved lined on matlab plot

From: Nasser M. Abbasi

Date: 26 Apr, 2013 01:50:51

Message: 2 of 8

On 4/25/2013 7:25 PM, chimi wrote:
> Hello can anyone tell me how can i make plot lines look curved?
>i have some points and when i make a plot the lines are straight
>but i want curved lines. Is there a command to do this for me?
> thank u
>


Look at spline() for cubic poly, or for general case, look at
using interp.

--Nasser
  

Subject: curved lined on matlab plot

From: chimi

Date: 26 Apr, 2013 02:39:09

Message: 3 of 8

"Nasser M. Abbasi" wrote in message <klcmhu$6ml$1@speranza.aioe.org>...
> On 4/25/2013 7:25 PM, chimi wrote:
> > Hello can anyone tell me how can i make plot lines look curved?
> >i have some points and when i make a plot the lines are straight
> >but i want curved lines. Is there a command to do this for me?
> > thank u
> >
>
>
> Look at spline() for cubic poly, or for general case, look at
> using interp.
>
> --Nasser
>

i think it doesnt work. i have something like that plot(arr_rec(:,j),'LineWidth',1.5,'color',cc(j,:));
how can i use it?

Subject: curved lined on matlab plot

From: Nasser M. Abbasi

Date: 26 Apr, 2013 02:51:16

Message: 4 of 8

On 4/25/2013 9:39 PM, chimi wrote:
> "Nasser M. Abbasi" wrote in message <klcmhu$6ml$1@speranza.aioe.org>...
>> On 4/25/2013 7:25 PM, chimi wrote:
>>> Hello can anyone tell me how can i make plot lines look curved?
>>> i have some points and when i make a plot the lines are straight
>>> but i want curved lines. Is there a command to do this for me?
>>> thank u
>>>
>>
>>
>> Look at spline() for cubic poly, or for general case, look at
>> using interp.
>>
>> --Nasser
>>
>
> i think it doesnt work. i have something like that plot(arr_rec(:,j),'LineWidth',1.5,'color',cc(j,:));
> how can i use it?
>

humm.. It works for me?

---------------------
N=20;
A=rand(N);
cs=spline(1:N,A(:,1));
plot(1:N,A(:,1),'o',1:N,ppval(cs,1:N),'-')
xx=linspace(1,N,200);
plot(1:N,A(:,1),'o',xx,ppval(cs,xx),'-')
---------------------------

--Nasser

Subject: curved lined on matlab plot

From: chimi

Date: 26 Apr, 2013 03:28:08

Message: 5 of 8

"Nasser M. Abbasi" wrote in message <klcq37$dmv$1@speranza.aioe.org>...
> On 4/25/2013 9:39 PM, chimi wrote:
> > "Nasser M. Abbasi" wrote in message <klcmhu$6ml$1@speranza.aioe.org>...
> >> On 4/25/2013 7:25 PM, chimi wrote:
> >>> Hello can anyone tell me how can i make plot lines look curved?
> >>> i have some points and when i make a plot the lines are straight
> >>> but i want curved lines. Is there a command to do this for me?
> >>> thank u
> >>>
> >>
> >>
> >> Look at spline() for cubic poly, or for general case, look at
> >> using interp.
> >>
> >> --Nasser
> >>
> >
> > i think it doesnt work. i have something like that plot(arr_rec(:,j),'LineWidth',1.5,'color',cc(j,:));
> > how can i use it?
> >
>
> humm.. It works for me?
>
> ---------------------
> N=20;
> A=rand(N);
> cs=spline(1:N,A(:,1));
> plot(1:N,A(:,1),'o',1:N,ppval(cs,1:N),'-')
> xx=linspace(1,N,200);
> plot(1:N,A(:,1),'o',xx,ppval(cs,xx),'-')
> ---------------------------
>
> --Nasser

thank u i think it works but i need little more help please..
i have the following part of code, i am trying to apply your part of code but it still doesnt work on my code. How can i do that?
for j=1:12
    plot(arr_rec(:,j),'LineWidth',1.5,'color',cc(j,:));
end
thank u again

Subject: curved lined on matlab plot

From: Nasser M. Abbasi

Date: 26 Apr, 2013 04:32:51

Message: 6 of 8

On 4/25/2013 10:28 PM, chimi wrote:

>> ---------------------
>> N=20;
>> A=rand(N);
>> cs=spline(1:N,A(:,1));
>> plot(1:N,A(:,1),'o',1:N,ppval(cs,1:N),'-')
>> xx=linspace(1,N,200);
>> plot(1:N,A(:,1),'o',xx,ppval(cs,xx),'-')
>> ---------------------------
>>
>> --Nasser
>

> thank u i think it works but i need little more help please..
> i have the following part of code, i am trying to apply your part of code
>but it still doesnt work on my code. How can i do that?
> for j=1:12
> plot(arr_rec(:,j),'LineWidth',1.5,'color',cc(j,:));
> end
> thank u again
>

Just add the spline code in there, inside the loop.
something like:

------------------------
N=12;
close all;
arr_rec=rand(N);
for j=1:N
     xx = 0:.25:N;
     yy = spline(1:N,arr_rec(:,j),xx);
     figure(j);
     plot(1:N,arr_rec(:,j),'o-',xx,yy,'-');
end
------------------------------

Subject: curved lined on matlab plot

From: Nasser M. Abbasi

Date: 26 Apr, 2013 04:35:28

Message: 7 of 8

On 4/25/2013 11:32 PM, Nasser M. Abbasi wrote:

> ------------------------
> N=12;
> close all;
> arr_rec=rand(N);
> for j=1:N
> xx = 0:.25:N;
> yy = spline(1:N,arr_rec(:,j),xx);
> figure(j);
> plot(1:N,arr_rec(:,j),'o-',xx,yy,'-');
> end
> ------------------------------
>

You can remove the line 'xx = 0:.25:N' to outside
the loop ofcourse since it is invariant.

--Nasser

Subject: curved lined on matlab plot

From: chimi

Date: 26 Apr, 2013 04:57:09

Message: 8 of 8

"Nasser M. Abbasi" wrote in message <kld01l$pau$1@speranza.aioe.org>...
> On 4/25/2013 10:28 PM, chimi wrote:
>
> >> ---------------------
> >> N=20;
> >> A=rand(N);
> >> cs=spline(1:N,A(:,1));
> >> plot(1:N,A(:,1),'o',1:N,ppval(cs,1:N),'-')
> >> xx=linspace(1,N,200);
> >> plot(1:N,A(:,1),'o',xx,ppval(cs,xx),'-')
> >> ---------------------------
> >>
> >> --Nasser
> >
>
> > thank u i think it works but i need little more help please..
> > i have the following part of code, i am trying to apply your part of code
> >but it still doesnt work on my code. How can i do that?
> > for j=1:12
> > plot(arr_rec(:,j),'LineWidth',1.5,'color',cc(j,:));
> > end
> > thank u again
> >
>
> Just add the spline code in there, inside the loop.
> something like:
>
> ------------------------
> N=12;
> close all;
> arr_rec=rand(N);
> for j=1:N
> xx = 0:.25:N;
> yy = spline(1:N,arr_rec(:,j),xx);
> figure(j);
> plot(1:N,arr_rec(:,j),'o-',xx,yy,'-');
> end
> ------------------------------

It works! thank u so much! :))

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