필터 지우기
필터 지우기

Overlapping graphs from multiple files for comparison

조회 수: 5 (최근 30일)
Harsimran Singh
Harsimran Singh 2023년 3월 12일
댓글: Harsimran Singh 2023년 3월 12일
I am working on a set of data which has 1000 files. Two of the exmaple files are attached.
Output needed:
I am looking for a way,
  • To read multiple (1000 files from a desired folder, one after another)
  • Plot Three graphs, one for each column (X,Y,Z)
  • Need all three graphs with overlapping ability, such that each graph contains overlapping of the particular column from the each file
  • Need legends as "file name from each file".
Would be thankful if you can help me on this.
Thanks in advance, Harsimran Singh

채택된 답변

Cameron
Cameron 2023년 3월 12일
Point #3 was confusing, but this is what it should look like. In this case, I've plotted the X, Y, and Z variables on three separate plots because of the ambiguity of point 3. If you are looking to have a legend with all 1000 files in it, you will not like the result. Again, this could be me misunderstanding your question. If that is the case, please clarify.
[file,path,indx] = uigetfile('.xlsx','MultiSelect','on');
if indx == 0; error('No file selected'); end %nothing selected
cd(path) %change directory
if ~iscell(file); file = {file}; end %if you only select one file
fig1 = figure;
ax1 = uiaxes(fig1);
hold(ax1,'on')
fig2 = figure;
ax2 = uiaxes(fig2);
hold(ax2,'on')
fig3 = figure;
ax3 = uiaxes(fig3);
hold(ax3,'on')
for x = 1:length(file)
fileData = readtable(string(file(x)));
plot(ax1,fileData.X,'o') %plotting just X data
plot(ax2,fileData.Y,'o') %plotting just Y data
plot(ax3,fileData.Z,'o') %plotting just Z data
end
hold(ax1,'off')
hold(ax2,'off')
hold(ax3,'off')
legend(ax1,extractBefore(file,'.'))
legend(ax2,extractBefore(file,'.'))
legend(ax3,extractBefore(file,'.'))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by