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:
plotting with LineSpec contained in vector

Subject: plotting with LineSpec contained in vector

From: Ulrik Nash

Date: 17 Oct, 2011 23:09:13

Message: 1 of 6

Why won't the following trick work for line specification?

t = 1:timeperiods;
line_colour = [0 0 0; 0 0 0; 0 0 0]
line_thickness = [1; 1; 1]
line_style = char('-','--',':')
for i = 1:num_files
plot(t,A(num_lables + 1:timeperiods + num_lables,i),'Color',line_colour(i,:),'LineWidth',line_thickness(i,:),'LineSpec',line_style(i,:))
hold all
plot(t,B(num_lables + 1:timeperiods + num_lables,i),'Color',line_colour(i,:),'LineWidth',line_thickness(i,:),'LineSpec',line_style(i,:))
end

Subject: plotting with LineSpec contained in vector

From: Parag S. Chandakkar

Date: 18 Oct, 2011 00:37:12

Message: 2 of 6

On Oct 17, 4:09 pm, "Ulrik Nash" <u...@sam.sdu.dk> wrote:
> Why won't the following trick work for line specification?
>
> t = 1:timeperiods;
> line_colour = [0 0 0; 0 0 0; 0 0 0]
> line_thickness = [1; 1; 1]
> line_style = char('-','--',':')
> for i = 1:num_files
> plot(t,A(num_lables + 1:timeperiods + num_lables,i),'Color',line_colour(i,:),'LineWidth',line_thickness(i,:),'Lin eSpec',line_style(i,:))
> hold all
> plot(t,B(num_lables + 1:timeperiods + num_lables,i),'Color',line_colour(i,:),'LineWidth',line_thickness(i,:),'Lin eSpec',line_style(i,:))
> end

This works in a similar fashion... there are some errors of index
exceed... but that should be fine... A and B are 5x5 matrices I have
defined.

t = 1:3;
line_colour = [0 0 0; 0 0 0; 0 0 0]
line_thickness = [1; 1; 1]
line_style = {'-r*','--mo',':bs'};
for i = 1:3
plot(t,A(2:1+timeperiods,i),line_style{i})
hold all
plot(t,B(2:1+timeperiods,i,i),line_style{i});
end

Hope this helps.
Regards,
-Parag S. Chandakkar.

Subject: plotting with LineSpec contained in vector

From: Ulrik Nash

Date: 18 Oct, 2011 03:22:26

Message: 3 of 6

"Parag S. Chandakkar" <parag2489@gmail.com> wrote in message <6a15844c-7180-47a7-aed8-d1485a0d5f86@g27g2000pro.googlegroups.com>...
> On Oct 17, 4:09 pm, "Ulrik Nash" <u...@sam.sdu.dk> wrote:
> > Why won't the following trick work for line specification?
> >
> > t = 1:timeperiods;
> > line_colour = [0 0 0; 0 0 0; 0 0 0]
> > line_thickness = [1; 1; 1]
> > line_style = char('-','--',':')
> > for i = 1:num_files
> > plot(t,A(num_lables + 1:timeperiods + num_lables,i),'Color',line_colour(i,:),'LineWidth',line_thickness(i,:),'Lin eSpec',line_style(i,:))
> > hold all
> > plot(t,B(num_lables + 1:timeperiods + num_lables,i),'Color',line_colour(i,:),'LineWidth',line_thickness(i,:),'Lin eSpec',line_style(i,:))
> > end
>
> This works in a similar fashion... there are some errors of index
> exceed... but that should be fine... A and B are 5x5 matrices I have
> defined.
>
> t = 1:3;
> line_colour = [0 0 0; 0 0 0; 0 0 0]
> line_thickness = [1; 1; 1]
> line_style = {'-r*','--mo',':bs'};
> for i = 1:3
> plot(t,A(2:1+timeperiods,i),line_style{i})
> hold all
> plot(t,B(2:1+timeperiods,i,i),line_style{i});
> end
>
> Hope this helps.
> Regards,
> -Parag S. Chandakkar.


Thank you Parag, but it doesn\t appear to work as intended. The colours in the line_colour vector and the line thickness of in line_thickness vector now do not appear to be incorporated.

Any other ideas?

Subject: plotting with LineSpec contained in vector

From: salman

Date: 18 Oct, 2011 06:33:08

Message: 4 of 6

"Ulrik Nash" <uwn@sam.sdu.dk> wrote in message <j7irdi$pd3$1@newscl01ah.mathworks.com>...
> "Parag S. Chandakkar" <parag2489@gmail.com> wrote in message <6a15844c-7180-47a7-aed8-d1485a0d5f86@g27g2000pro.googlegroups.com>...
> > On Oct 17, 4:09 pm, "Ulrik Nash" <u...@sam.sdu.dk> wrote:
> > > Why won't the following trick work for line specification?
> > >
> > > t = 1:timeperiods;
> > > line_colour = [0 0 0; 0 0 0; 0 0 0]
> > > line_thickness = [1; 1; 1]
> > > line_style = char('-','--',':')
> > > for i = 1:num_files
> > > plot(t,A(num_lables + 1:timeperiods + num_lables,i),'Color',line_colour(i,:),'LineWidth',line_thickness(i,:),'Lin eSpec',line_style(i,:))
> > > hold all
> > > plot(t,B(num_lables + 1:timeperiods + num_lables,i),'Color',line_colour(i,:),'LineWidth',line_thickness(i,:),'Lin eSpec',line_style(i,:))
> > > end
> >
> > This works in a similar fashion... there are some errors of index
> > exceed... but that should be fine... A and B are 5x5 matrices I have
> > defined.
> >
> > t = 1:3;
> > line_colour = [0 0 0; 0 0 0; 0 0 0]
> > line_thickness = [1; 1; 1]
> > line_style = {'-r*','--mo',':bs'};
> > for i = 1:3
> > plot(t,A(2:1+timeperiods,i),line_style{i})
> > hold all
> > plot(t,B(2:1+timeperiods,i,i),line_style{i});
> > end
> >
> > Hope this helps.
> > Regards,
> > -Parag S. Chandakkar.
>
>
> Thank you Parag, but it doesn\t appear to work as intended. The colours in the line_colour vector and the line thickness of in line_thickness vector now do not appear to be incorporated.
>
> Any other ideas?

instead why dont you just plot the curves and if you want to just change the colors and thickness, you can control that from the editing tool box in the plot window. see the editing tool box window of the plot, you can find alot of things there

Subject: plotting with LineSpec contained in vector

From: Parag S. Chandakkar

Date: 18 Oct, 2011 06:40:38

Message: 5 of 6

On Oct 17, 8:22 pm, "Ulrik Nash" <u...@sam.sdu.dk> wrote:
> "Parag S. Chandakkar" <parag2...@gmail.com> wrote in message <6a15844c-7180-47a7-aed8-d1485a0d5...@g27g2000pro.googlegroups.com>...
>
>
>
>
>
>
>
>
>
> > On Oct 17, 4:09 pm, "Ulrik Nash" <u...@sam.sdu.dk> wrote:
> > > Why won't the following trick work for line specification?
>
> > > t = 1:timeperiods;
> > > line_colour = [0 0 0; 0 0 0; 0 0 0]
> > > line_thickness = [1; 1; 1]
> > > line_style = char('-','--',':')
> > > for i = 1:num_files
> > > plot(t,A(num_lables + 1:timeperiods + num_lables,i),'Color',line_colour(i,:),'LineWidth',line_thickness(i,:),'Lin eSpec',line_style(i,:))
> > > hold all
> > > plot(t,B(num_lables + 1:timeperiods + num_lables,i),'Color',line_colour(i,:),'LineWidth',line_thickness(i,:),'Lin eSpec',line_style(i,:))
> > > end
>
> > This works in a similar fashion... there are some errors of index
> > exceed... but that should be fine... A and B are 5x5 matrices I have
> > defined.
>
> > t = 1:3;
> > line_colour = [0 0 0; 0 0 0; 0 0 0]
> > line_thickness = [1; 1; 1]
> > line_style = {'-r*','--mo',':bs'};
> > for i = 1:3
> > plot(t,A(2:1+timeperiods,i),line_style{i})
> > hold all
> > plot(t,B(2:1+timeperiods,i,i),line_style{i});
> > end
>
> > Hope this helps.
> > Regards,
> > -Parag S. Chandakkar.
>
> Thank you Parag, but it doesn\t appear to work as intended. The colours in the line_colour vector and the line thickness of in line_thickness vector now do not appear to be incorporated.
>
> Any other ideas?

Ok. Above code can be easily modified to a complete working code:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
LineWidthCell={1,2,3,4,5};
MarkerCell={'+','*','x','s','d'};
MarkerEdgeColorCell={'r','y','b','k','m'};

for i=1:5
plot(A(i,:),LineStyleCell{i},'LineWidth',LineWidthCell{i},'Marker',MarkerCell{i},'MarkerEdgeColor',MarkerEdgeColorCell{i});
hold on
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Hope this helps.
Regards,
- Parag S. Chandakkar.

Subject: plotting with LineSpec contained in vector

From: Ulrik Nash

Date: 18 Oct, 2011 15:45:15

Message: 6 of 6

"Parag S. Chandakkar" <parag2489@gmail.com> wrote in message <45c15044-ee85-4f2b-abfc-78fe497fe0e7@l10g2000pra.googlegroups.com>...
> On Oct 17, 8:22 pm, "Ulrik Nash" <u...@sam.sdu.dk> wrote:
> > "Parag S. Chandakkar" <parag2...@gmail.com> wrote in message <6a15844c-7180-47a7-aed8-d1485a0d5...@g27g2000pro.googlegroups.com>...
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > On Oct 17, 4:09 pm, "Ulrik Nash" <u...@sam.sdu.dk> wrote:
> > > > Why won't the following trick work for line specification?
> >
> > > > t = 1:timeperiods;
> > > > line_colour = [0 0 0; 0 0 0; 0 0 0]
> > > > line_thickness = [1; 1; 1]
> > > > line_style = char('-','--',':')
> > > > for i = 1:num_files
> > > > plot(t,A(num_lables + 1:timeperiods + num_lables,i),'Color',line_colour(i,:),'LineWidth',line_thickness(i,:),'Lin eSpec',line_style(i,:))
> > > > hold all
> > > > plot(t,B(num_lables + 1:timeperiods + num_lables,i),'Color',line_colour(i,:),'LineWidth',line_thickness(i,:),'Lin eSpec',line_style(i,:))
> > > > end
> >
> > > This works in a similar fashion... there are some errors of index
> > > exceed... but that should be fine... A and B are 5x5 matrices I have
> > > defined.
> >
> > > t = 1:3;
> > > line_colour = [0 0 0; 0 0 0; 0 0 0]
> > > line_thickness = [1; 1; 1]
> > > line_style = {'-r*','--mo',':bs'};
> > > for i = 1:3
> > > plot(t,A(2:1+timeperiods,i),line_style{i})
> > > hold all
> > > plot(t,B(2:1+timeperiods,i,i),line_style{i});
> > > end
> >
> > > Hope this helps.
> > > Regards,
> > > -Parag S. Chandakkar.
> >
> > Thank you Parag, but it doesn\t appear to work as intended. The colours in the line_colour vector and the line thickness of in line_thickness vector now do not appear to be incorporated.
> >
> > Any other ideas?
>
> Ok. Above code can be easily modified to a complete working code:
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> LineWidthCell={1,2,3,4,5};
> MarkerCell={'+','*','x','s','d'};
> MarkerEdgeColorCell={'r','y','b','k','m'};
>
> for i=1:5
> plot(A(i,:),LineStyleCell{i},'LineWidth',LineWidthCell{i},'Marker',MarkerCell{i},'MarkerEdgeColor',MarkerEdgeColorCell{i});
> hold on
> end
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> Hope this helps.
> Regards,
> - Parag S. Chandakkar.


Thank you very much Parag, much appreciated!

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