How to index characters inside a multidimensional tall array?

3 views (last 30 days)
I am working with some relatively large datasets on Matlab 2019a.
I'm trying to adapt an existing script to leverage tall arrays, and I'm encountering problems with indexing strings inside of these tall arrays.
Here I read in all rows of a 2-column .csv file. I store the two columns in a 1x2 tall cell array:
RecvFile = fopen(receive_file,'r');
fgetl(RecvFile); % ignore heading row
RecvPackets = tall(textscan(RecvFile,'%s%s', 'delimiter', ','));
The first column is a timestamp ("time"); the second column is a string of hex values ("data").
I then enter a for loop to compare the first 2 and last 2 hex values in each data string to the expected values. The goal here is to remove rows that do not have the proper header and trailer.
Before I casted RecvPackets to tall, I was able to use strcmp and index the strings inside the non-tall 1x2 cell array like so:
strcmp(RecvPackets{1,2}{packet_num}(1:2),'CC')
I can't figure out how to achieve the same thing now with RecvPackets as tall. I know that curly brace indexing does not work with tall arrays, but this does not work:
strcmp(RecvPackets(packet_num,2)(1:2),'CC')
I've tried a couple other ways but they look ridiculous so I'll refrain from copying them here.
The only other reasonable idea I came up with was that perhaps I need to evaluate the index before passing it to strcmp, something like this:
strcmp(gather(RecvPackets(packet_num,2)(1:2)),'CC')
But no such luck.
Does anyone know how to access character/string indices inside a tall 1x2 matrix?
Thanks in advance,
Cole
----------------------------------------------------------------------------------------------------
Matlab 2019a (9.6.0.1072779)
on
Windows 10 Enterprise (10.0.17134 N/A Build 17134)
  1 Comment
Cole Meyers
Cole Meyers on 11 Nov 2019
Also, if someone knows a better way to achieve my end goal of removing rows that don't meet certain string conditions, I'm all ears. It just has to be compatible with tall arrays.

Sign in to comment.

Answers (1)

Gina Cosme
Gina Cosme on 11 Nov 2019
1x2 matrix is quite tricky try to use some version 2 1x2 code maybe it help
  1 Comment
Cole Meyers
Cole Meyers on 11 Nov 2019
Hi Gina,
Thanks for your reply. Can you explain a little further? I am not a Matlab pro.
Thanks,
Cole

Sign in to comment.

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!