フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Picking values from .xlsx

2 ビュー (過去 30 日間)
Giovanni Gardan
Giovanni Gardan 2020 年 7 月 25 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have a table A in the workspace (10X6), which is originally from a .xlsx file.
In the first column, which is called {'Name'}, of table A, I have the name of some objects as you can see in the following figure
In my workspace I have a (10X2) string array (B), which in the first column has the same name of first column of table A, but with two differences: they aren't in the same order and some names have a '-' in front of the name; as you can see in the following pic
I'd like to take the corresponding numbers of column 3 of the Table A and put in the second column of array B, but i can't do it because '-'
make Matlab don't recognize the string. I put the for loop i made, how can I modify my loop?
for k = 1:size(B(:,2),1)
k1 = find(string(table2array(A(:,{'Name'}))) == ...
string(B(k,1)));
RIS_V(k,2) = table2array(TENS(k1,{'u_Magnitude'}));
end
  2 件のコメント
dpb
dpb 2020 年 7 月 25 日
As per usual, it would be easier to provide working code examples if had the data at hand, but...needs additional clarification first, anyways--
Are 'Bus,NNN", "-Bus,NNN", "Bus,NNN(M)" indeed all referring to the same item in the table variable A.Name?
If so, the simplest solution would probably be to turn all to a categorical() variable and create the catnames variable to coincide with the table name in the B array.
Alternatively, you can use partial string comparisons, but I think it's more of a pain to implement...
Attach A and B as .mat file containing them and folks will be able to spearmint w/ alternatives much more easily than if have to make stuff up...
Image Analyst
Image Analyst 2020 年 7 月 25 日
編集済み: Image Analyst 2020 年 7 月 25 日
Attach your workbook with the paperclip icon, and show us your call to readtable().

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by