How to plot multiple values of a variable in one graph?

조회 수: 11 (최근 30일)
James Sheldon
James Sheldon 2018년 6월 12일
댓글: James Sheldon 2018년 6월 20일
I put 5 txt files into a loop to graph the FFT and PDS continuously. They are audio files converted to txt files. I used "findpeaks" to find all peaks in the graphs. I then used "max" to find the max peak in each of the 5 graphs. I got 5 answers for the same variable. (l=max(v)). How do I plot all of these answers in one graph? Below is an example of my work. Here is the values I received for the max for each graph, l = 7.1537e+08, l = 1.3054e+09, l = 2.4736e+09, l = 3.4960e+09, l = 2.4039e+09
numfiles = 5;
y = cell(1, numfiles);
for k = 1:numfiles
myfilename = sprintf('file%d.txt', k);
y{k} = importdata(myfilename);
plot(y{k})
m=(abs(fft(y{k})));
%n=m(1:y{k}/2);
%plot(n);
pwelch(y{k})
v= pwelch(y{k})
plot(v)
xlim([0 4000])
findpeaks(v)
l= max(v)
end
  댓글 수: 2
Matt Dickson
Matt Dickson 2018년 6월 12일
To clarify, you want to plot the maximum value (you call it l). What are you plotting it against? Index of the file?

댓글을 달려면 로그인하십시오.

답변 (2개)

Arun Mathamkode
Arun Mathamkode 2018년 6월 15일
I believe you want to plot the maximum value for each graph against the index file. You can simply store maximum values in l as an array and plot the array.
In the loop, change l=max(v) to l(k)=max(v) and use plot(l) after the loop.
  댓글 수: 2
James Sheldon
James Sheldon 2018년 6월 20일
This is not exactly what I want. I want to plot the values in a somewhat waterfall type graph so I can stack up numerous values against one another to find the peak value. I will use this to set limits. So I want to plot each 1 values against the max height reached.
James Sheldon
James Sheldon 2018년 6월 20일
I want more of a scatter plot of the data so I can compare the results.

댓글을 달려면 로그인하십시오.


James Sheldon
James Sheldon 2018년 6월 19일
Okay. I will try that and see how it turns out. Thank you.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by