Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Picking values from .xlsx

1 visualización (últimos 30 días)
Giovanni Gardan
Giovanni Gardan el 25 de Jul. de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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 comentarios
dpb
dpb el 25 de Jul. de 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 el 25 de Jul. de 2020
Editada: Image Analyst el 25 de Jul. de 2020
Attach your workbook with the paperclip icon, and show us your call to readtable().

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by