필터 지우기
필터 지우기

Plotting multiple data files on 1 plot

조회 수: 4 (최근 30일)
Jared
Jared 2011년 11월 2일
Sounds simple enough. I know I can just use plot, hold on, plot, hold on, etc, to overlay multiple data files in one plot figure.
The problem is, I have a variable number of multi-column data files. I can easily figure out how many files that need to be plotted, but I don't want to have to do a case by case basis: if files=1, plot 1, if files=2, plot 1 & 2, etc.
Is there any way to store all of the data in 1 matrix, and just plot whatever data is in the matrix?
Ex (data columns): x1 y1 x2 y2 x3 y3
That way, it doesn't matter how many sets of data are in the matrix, I will just have to call that matrix with the plot command.

채택된 답변

Walter Roberson
Walter Roberson 2011년 11월 2일
Use a cell array
Ex = {x1 y1 x2 y2 x3 y3};
Then,
plot(Ex{:})
Or just go ahead and plot them on the fly as you outlined. You only need the "hold on" after the first one. Your plot does not need to know how many you will be plotting (unless there is something you have not mentioned.)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by