How do I update several graphs in one loop?

조회 수: 2 (최근 30일)
Matthew Koebbe
Matthew Koebbe 2022년 6월 28일
댓글: dpb 2022년 6월 28일
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