Azzera filtri
Azzera filtri

Overlapping graphs from multiple files for comparison

5 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Cameron
Cameron il 12 Mar 2023
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,'.'))

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by