MATLAB Answers


How to index characters inside a multidimensional tall array?

Asked by Cole Meyers on 11 Nov 2019 at 2:36
Latest activity Commented on by Cole Meyers on 11 Nov 2019 at 15:09
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:
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:
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:
But no such luck.
Does anyone know how to access character/string indices inside a tall 1x2 matrix?
Thanks in advance,
Matlab 2019a (
Windows 10 Enterprise (10.0.17134 N/A Build 17134)

  1 Comment

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.




1 Answer

Answer by Gina Cosme on 11 Nov 2019 at 2:49

1x2 matrix is quite tricky try to use some version 2 1x2 code maybe it help

  1 Comment

Hi Gina,
Thanks for your reply. Can you explain a little further? I am not a Matlab pro.

Sign in to comment.