Effacer les filtres
Effacer les filtres

Comparison of two unequal length files.

3 vues (au cours des 30 derniers jours)
Devang Anadkat
Devang Anadkat le 13 Mar 2021
Commenté : Devang Anadkat le 13 Mar 2021
I have two .csv files of unequal length. each file has two colomns and one has 50000 rows and other has 27000 rows. in this first colomn is of wavelengths and other is of intensity. I want to get data in which the wavelengths of both files are equal and also want corrsponding intensities. so how can i find it using program?
thanking you in advance.

Réponse acceptée

Jan
Jan le 13 Mar 2021
  1. Import the files. (Is this a part of your problem?)
  2. Search the intersection of the common variable with the command intersect . The 2nd and 3rd output give you the overlapping indices.
  3 commentaires
Jan
Jan le 13 Mar 2021
Modifié(e) : Jan le 13 Mar 2021
I do not know, how the intensities are represented. Did you mention, if you your data are matrices with a specific number pof columns? A small example would be useful. With some guessing:
A = [1; 3; 2; 17] % 1st file
B = [0, 0.1; 1, 0.2; 2, 0.3; 3 0.4; 17, 0.5; 24, 0.6]; % 2nd file
[Common, iA, iB] = intersect(A, B(:, 1));
CommonIntesity = B(iB, 2)
A(iA, 2) = B(iB, 2) % Maybe wanted...
Devang Anadkat
Devang Anadkat le 13 Mar 2021
this is first file
4.0004000e+02 2.2576667e+03
4.0006000e+02 2.7194000e+03
4.0008000e+02 2.9347143e+03
4.0010000e+02 3.0555556e+03 &
this is second file
400.04 0.2702
400.05 0.27026
400.06 0.27031
400.07 0.27036
400.08 0.27041
in this both files first colomn is of wavelength and other one is of intensity. i got the wavelength which are same in both files say 400.04 400.06 etc.. but in both files intensity is different corresponding to that same wavelength. so now i want the table in which i got first colomn is of wavelength which are common in both file second colomn is of intensity which is in file 1 corresponding to common wavelength and 3rd colomn is of intensity which is in file 2.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by