How to select numbers in a cell array?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kimberly Cardillo
am 16 Jun. 2020
Beantwortet: madhan ravi
am 16 Jun. 2020
I have a call array called newCell that is 1x6 and each cell is 5x1 as seen in the picture below. I want to say that for each cell, if the number in the first row is greater than the number in the second row, then my new array, T1 is equal to 1. If that is not true, then it is equal to 0. For example, from the picture, the first row in the first cell is 49 and the second row in the first cell is 33 so the first value in T1 should be 1.
The code I have right now is seen below (where i=[1:6]).
if newCell{i}(1,i)>newCell{i}(2,i)
T1(i)=1;
else
T1(i)=0;
end
Thanks!
0 Kommentare
Akzeptierte Antwort
KSSV
am 16 Jun. 2020
Let C be your 1*6 cell where each cell has 5*1 elements
M = cell2mat(C) ;
iwant = M(1,:) > M(2,:)
0 Kommentare
Weitere Antworten (1)
madhan ravi
am 16 Jun. 2020
T = arrayfun(@(x) newCell{x}(1,1) > newCell{x}(2,1),...
1:numel(newCell))
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!