Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.8K Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Use ListPlot to draw all the elements of a vector?

Posted 6 years ago

Hello everyone.

I have a vector which contains 81 realizations of a stochastic process. I need to plot them together to see the differences. Until now I have written my code as

g1 = ListPlot[{matRealizations[[1]], matRealizations[[2]], 
   matRealizations[[3]], matRealizations[[4]], matRealizations[[5]], 
   matRealizations[[6]], matRealizations[[7]], matRealizations[[8]], 
   matRealizations[[9]], xvsyMean}, 
  Joined -> {True, True, True, True, True, True, True, True, True, 
    False}]

However, with 81 realizations this is unfeasible.

I have tried

g1 = ListPlot[{matRealizations[[1 ;; 5]], Joined -> {True}}]

but an error appears.

Can someone please tell me if there is a way for me to plot all 81 realizations without having to write matRealizations[[i]], eighty one times?

Thank you very much. Jaime.

POSTED BY: Jaime de la Mota
4 Replies

There are many ways, I will show one of them. Let a random process be described by a function

matRealizations = 
  Table[Sin[RandomReal[-1, 1] t + RandomReal[]], {81}];

You can display them all together or selectively

Show[Table[
  Plot[matRealizations[[i]], {t, -Pi, Pi}, PlotStyle -> Hue[i/81], 
   PlotRange -> {-1, 1}], {i, 1, 81, 1}]]
{Show[Table[
   Plot[matRealizations[[i]], {t, -Pi, Pi}, PlotStyle -> Hue[i/81], 
    PlotRange -> {-1, 1}], {i, 1, 7, 1}]], 
 Show[Table[
   Plot[matRealizations[[i]], {t, -Pi, Pi}, PlotStyle -> Hue[i/81], 
    PlotRange -> {-1, 1}], {i, {1, 5, 61, 70}}]]}

Figure 1

Posted 6 years ago

Hi Jamie,

What is the structure of matRealizations? If it is a list of numbers or a list of lists of points then this should work.

ListPlot[matRealizations, Joined -> True]

If not, you can always generate the list using Table.

ListPlot[Table[matRealizations[[i]], {i, 81}], Joined -> True]
POSTED BY: Rohit Namjoshi

Thanks for your answer!

Regards. Jaime.

POSTED BY: Jaime de la Mota

Hello! I have tested your solution and the first one works finely. Thank you very much. Regards. Jaime.

POSTED BY: Jaime de la Mota
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard