元胞结构体中获取某一结构体的索引值。
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
新锦江娱乐开户热线【微8785092】
il 21 Mag 2023
Risposto: 新锦江娱乐开户中心【微8785092】
il 21 Mag 2023
现有一元胞结构体,请问获取A在Person中的索引值?
clear
clc
Person{1}.name = 'zhang';
Person{1}.age = 20;
Person{2}.name = 'li';
Person{2}.age = 21;
Person{3}.name = 'wang';
Person{3}.age = 22;
A.name = 'zhang';
A.age = 20;
% 如何求A在Person中的索引
% Index = find(cellfun(@(x) strcmp(x , A), Person)); % 无效
0 Commenti
Risposta accettata
新锦江娱乐开户中心【微8785092】
il 21 Mag 2023
Index = find( cellfun( @( x ) isequaln( x , A ), Person ) )
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!