Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Picking values from .xlsx
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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
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!