[英]How do I use a for loop in Matlab to select rows where the values are different between two columns?
[英]I am trying to extract the rows with the same x values from two different files in matlab, how can I do it?
更清楚的是,我想要的是從file1生成file3但是在文件2中生成x值。
例:
file 1:
x1=[1 2 3 4 5 6 7 8 9 10]'
y1=[11 22 33 44 55 66 77 88 99 00]'
file 2:
x2=[3 4 5 8 9]'
y2=[333 444 555 888 999]'
file 3:
x2=[3 4 5 8 9]'
y2=[33 44 55 88 99]'
使用ISMEMBER查找x1的哪些值在x2中,以及它們的位置。
x1=[1 2 3 4 5 6 7 8 9 10]'
y1=[11 22 33 44 55 66 77 88 99 00]'
x2=[3 4 5 8 9]'
y2=[333 444 555 888 999]'
x3 = x2;
y3 = y1(ismember(x1,x2))
y3 =
33
44
55
88
99
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.