Comparing elements between a character and a numerical column
Show older comments
Not sure if this is written correctly. Suppose there is a cell array where the first column holds characters ie) 'con', 'func', key', and the second column holds numerical values ie) 74 85 98. For x = 1:length(Event) [where event is the array], if event{x,1} is 'con' AND the cell immediately after it (x+1) is 'key', take the horizontal values and place those in a new array. For example:
Column 1 = ['con', 'key', 'con', 'con', 'var', 'con', key'] Column 2 = [ 74 85 94 67 56 84 23]
The new array would look like Column 1 = ['con', 'key', 'con, 'key'] column 2 = [74 85 84 23]
for x = 1:length(event)
if event{x,1} == 'con' & event{x+1,1} == 'key'
iEvent = event{x,:}
end
end
One of the issues I think is that == does not work with characters?
Accepted Answer
More Answers (0)
Categories
Find more on Language Support in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!