Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
[HELP plz] How to seperate Column Data into values greater than and less than all into new Column
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi
I have a problem, where i get undefined function gt and so on...annoying and cant figure why..been searching the net and no luck. here is the question:
i have a matrix with: 137242x1 cell called V. containing some voltage. what i want this code to do is seperate the voltages so it makes a new Column with Values greater than 230 into 1 Cell for itself..and values less than 225 into another..and values remaining at 225-230.
i have for starters used for..but not working:
n = 1;
i = 0;
for i=1:length(V)
X = V > 230
end
help please :)
5 commentaires
Walter Roberson
le 18 Mar 2014
If U is a cell array then U' does not turn it into a vector: it takes the transpose of the cell array leaving a cell array as the result.
Réponses (1)
Walter Roberson
le 17 Mar 2014
If each cell contains exactly one scalar, then the simplest to program is
U = cell2mat(V);
and then work with the numeric matrix U in ways similar to what Metin showed.
idx1 = U > 230;
idx2 = U < 225;
idx3 = ~(idx1 | idx2);
k_1 = U(idx1);
k_2 = U(idx2);
k_3 = U(idx3);
2 commentaires
Walter Roberson
le 18 Mar 2014
Your cell array is not completely numeric. The string in your first cell is causing the problem.
Do as I showed above but starting with
U = cell2mat(V(2:end));
Provided that all the other entries are numeric scalars.
Question: do the cells hold strings rather than numeric values??
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!