How to compare a structure member with string ?
22 ビュー (過去 30 日間)
I am reading an excel file that contains one string column and one numerical. I want to
compare the strings read from excel with string variables in my code. here in the code
mulnames has a structure like
so I need to compare test1 and test2 names with a variable called filename. but doing the following, I get empty array. ( the condition says, if the first column name is equal
to the variable, take the corresponding number and put it in an array)
Walter Roberson 2020 年 5 月 6 日
編集済み: Walter Roberson 2020 年 5 月 6 日
Do not use size(fnames) there: use numel(fnames)
However you have the problem that you are using number of items belonging to fnames but the array mulnames might have a completely different size unrelated to that.
which can more easily be done as:
mulnames = readcell('Ms.xlsx');
mask = strcmp(filename, mulnames(:,1));
multip = mulnames(mask, 2);