Replacing numbers in dataset by string

3 visualizzazioni (ultimi 30 giorni)
Hello, could you help me please with this code:
for i=1:length(inoperationDatatree1.SystemSlices)
if (inoperationDatatree1.SystemSlices(i)>0 && inoperationDatatree1.SystemSlices(i)<=50)
elseif (inoperationDatatree1.SystemSlices(i)>51 && inoperationDatatree1.SystemSlices(i)<=100)
elseif (inoperationDatatree1.SystemSlices(i)>101 && inoperationDatatree1.SystemSlices(i)<=150)
else inoperationDatatree1.SystemSlices(i)={'>150'};
I need to replace each of row by interval...
  2 Commenti
David Young
David Young il 30 Gen 2016
Storing those strings is an unusual thing to want to do. Can you explain what the purpose is, because there might be a much better way to solve the underlying problem.
Radoslav Vandzura
Radoslav Vandzura il 30 Gen 2016
I want to do classification tree and before that i need adapt (modify) my dataset for that....

Accedi per commentare.

Risposta accettata

John BG
John BG il 30 Gen 2016
.. The dataset data type might be removed in a future release. To work with heterogeneous data, use the MATLAB® table data type instead. See MATLAB table documentation for more information ..
you seem to be attempting to cast a string in the place that you initially allocated to a number. If you had a cell, that would be fine, you can even replace numbers with entire arrays, or nesting cells inside cell positions.
why don't you translate your dataset into a table and start replacing table elements from there?
The Mathworks documentary starter example:
LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49];
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80];
T = table(Age,Height,Weight,BloodPressure,'RowNames',LastName)
pull some table elements with
ans =
Smith 38.00
ans =
Williams 125.00 83.00
Yet T(1,1)='38' does not work either
but if you convert your table to a cell
Now you can modify any field of the cell, you can have numbers next to strings in neighbouring cell fields.
Now mind the gap:
Tcell_1_1 is still a cell
if you try Tcell(1,1)='38' doesn't work but the following works:
and you see all Tcell fields containing cells but the (1,1) field where you just cast in a string.
Hope it helps, if so please click on thumbs up
  2 Commenti
Radoslav Vandzura
Radoslav Vandzura il 30 Gen 2016
But, when i have table yet, how can I do it in a cycle? Because I have many can i scan the entire table...?
Radoslav Vandzura
Radoslav Vandzura il 30 Gen 2016
I did it yet, thank you very very much, I really appreciate your help and time :)

Accedi per commentare.

Più risposte (0)


Scopri di più su Tables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by