MATLAB Answers

Different line style and color in cell

1 view (last 30 days)
olodyusuf
olodyusuf on 19 May 2020
Answered: Mehmed Saad on 19 May 2020
I have a 1 × 4 cell, with each cell containing an array of 1 × 15. I want to plot the cell using different line style and color.

  0 Comments

Sign in to comment.

Answers (1)

Mehmed Saad
Mehmed Saad on 19 May 2020
you can use for loop or you can use cellfun.
data= {rand(1,15) rand(1,15) rand(1,15) rand(1,15)};
line_style = {'-','--',':','-.'};
line_color = {'r','g','b','k'};
figure,hold on
cellfun(@(x,y,z) plot(x,'LineStyle',y,'LineWidth',2,'Color',z),data,line_style,line_color)

  0 Comments

Sign in to comment.

Products


Release

R2015a

Translated by