求教 如何快速查找对应序号并赋值。

描述:有A,B两个文件,A>B,第一列是编号。现在要把B中每个编号下的整行数据对应导入A
Size比较大,我这样很慢,请问有没有什么办法
clc;clear
a=xlsread('文件A')
b=xlsread('文件B')
i=a(:,1)
for k=1:23133
[m,n]=find(i==b(k,1))
a(m,:)=b(k,:)
end

 Réponse acceptée

posadan
posadan le 30 Mar 2023

0 votes

clc;clear
a = xlsread('文件A');
b= x lsread('文件B');
[~,loa] = ismember(b(:,1),a(:,1));
a(loa,:) = b;

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Centre d'aide 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