필터 지우기
필터 지우기

Comparison of two unequal length files.

조회 수: 3 (최근 30일)
Devang Anadkat
Devang Anadkat 2021년 3월 13일
댓글: Devang Anadkat 2021년 3월 13일
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.

채택된 답변

Jan
Jan 2021년 3월 13일
  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
Jan
Jan 2021년 3월 13일
편집: Jan 2021년 3월 13일
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 2021년 3월 13일
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.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by