How do I update several graphs in one loop?

2 次查看(过去 30 天)
I'm analyzing the results of a Monte Carlo run. I have 1,000 files of seven variables, each recorded at 2,001 timesteps. The data is stored as double floats. I want to generate six plots (the seventh variable is time) with overlays of each variable vs. time. At the end, I want six plots with 1,000 curves each.
I have a loop that cycles through the 1,000 files and extracts information from each. I'd like to build these graphs in the same loop. But I can only get a plot of the data read from the current file. How do I get six different plots to be "sticky"?
  4 个评论
Matthew Koebbe
Matthew Koebbe 2022-6-28
Since I'm processing and plotting this data in different ways, I'll try building the 3D array first. This is my first MATLAB script,so I built it in a piecewise, ad hoc manner. I'm sure it can be more efficient! Thanks for the tip. I do like writing efficient code.
dpb
dpb 2022-6-28
NB: when you get to plotting that plot() is vectorized to treat columns as separate variables -- and the x variable can be a vector while the y-values are a 2D array. Just the X vector length must match the number of rows in Y.
That's where you'll get the speedup -- there was a Q? just last week where an individual was plotting some 60K points in a loop and it was taking some 10 minutes or more...<60k-lines-on-one-plot-too-slow?> I'd suggest reading it for some other ideas -- even "only" 1000 lines on a single plot probably isn't the best idea.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by