Find the max amplitude of Frequency from text file
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a text file like this
0.000000,-1.721511E-5,-2.869001E-5
3.906250E-5,-1.859251E-5,-3.247638E-5
7.812500E-5,-2.083079E-5,-2.504133E-5
0.000117,-1.996991E-5,-2.779505E-5
0.000156,-1.866138E-5,-3.044551E-5
0.000195,-2.241480E-5,-2.982592E-5
0.000234,-2.027983E-5,-2.579860E-5
0.000273,-1.786938E-5,-2.497249E-5
0.000312,-1.910904E-5,-2.741642E-5
.......
0.000352,-1.749059E-5,-2.748526E-5
0.000391,-2.141618E-5,-2.855233E-5
0.000430,-2.062418E-5,-2.751968E-5
0.000469,-1.817929E-5,-2.696894E-5
0.000508,-1.511457E-5,-3.030782E-5
0.000547,-1.931565E-5,-2.597071E-5
0.000586,-1.855808E-5,-3.158142E-5
0.000625,-2.072748E-5,-3.054877E-5
0.000664,-2.072748E-5,-3.171910E-5
0.000703,-1.917791E-5,-3.047993E-5
0.000742,-2.289689E-5,-2.486922E-5
0.000781,-2.165723E-5,-2.941286E-5
0.000820,-2.076192E-5,-3.068646E-5
0.000859,-1.776607E-5,-2.583303E-5
0.000898,-1.728398E-5,-2.748526E-5
First colum is value of time, Second and 3rd colum is value of frequency at point 1 and 2. I need to get the max and the second max value of amplitude of frequency at point 1, because maybe there are some bad value of amplitude of frequency at point 1. Then, I need to export the value of the range in the black box. How can I do it.
0 commentaires
Réponses (2)
Abhiram Bhanuprakash
le 13 Mai 2015
Hi Vu,
In your case, since you have only text data (without character strings), I think you can save your data into a CSV file, and use 'csvread' to import the data into the MATLAB workspace. Documentation for 'csvread' is here
After you get the data into MATLAB, you can use it for further processing. For example, in your case, you can use something like:
a = csvread('data.csv'); %where data.csv file contains the data which you have pasted here
maxval = max(a(:,2)); %maximum of second column
Hope this helps,
Cheers!
Abhiram.
5 commentaires
Abhiram Bhanuprakash
le 13 Mai 2015
@vu: Sorry but I am not able to understand you. As Walter has asked, can you please define what you mean by a cycle?
Walter Roberson
le 13 Mai 2015
fid = fopen('YourFile.txt');
C = textscan(fid, '%f,%f,%f', 'CollectOutput', 1);
close(fid);
point1 = C{1}(:,2);
[up1, upa] = unique(point1);
maxp1 = up1(end);
maxp1pos = upa(end);
max2p1 = up1(end-1);
max2p1pos = upa(end-1);
Note that you have not clearly defined "second maximum" if what you might have is a peak over several values rather than a single bad point.
Voir également
Catégories
En savoir plus sur Text Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!