Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Picking values from .xlsx

2 Ansichten (letzte 30 Tage)
Giovanni Gardan
Giovanni Gardan am 25 Jul. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
dpb
dpb am 25 Jul. 2020
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 am 25 Jul. 2020
Bearbeitet: Image Analyst am 25 Jul. 2020
Attach your workbook with the paperclip icon, and show us your call to readtable().

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by