Azzera filtri
Azzera filtri

Error in string operation

3 visualizzazioni (ultimi 30 giorni)
klb
klb il 4 Lug 2020
Commentato: klb il 4 Lug 2020
Runs correctly first time. On second run, says "Error using == Comparison between logical and string is not supported."
What am I not doing right?
% Import file
file = string(extractFileText('my_text.pdf'))
% Break the file into lines
datachunks = splitlines(file)
% Eliminate empty lines
datachunks = datachunks(datachunks == "") % Error here. No change to anything preceeding this line for the second rerun. These 3 lines are literally the first 3 commands.
Thank you for your time in advance.

Risposta accettata

Steven Lord
Steven Lord il 4 Lug 2020
My guess is that on a later line of code you overwrite the datachunks variable (which previously contained a string array) with a logical array. If so then the next time you tried to compare it with "" you would receive this error.
>> true == ""
Error using ==
Comparison between logical and string is not supported.
  1 Commento
klb
klb il 4 Lug 2020
Well, ..Its a seveal page long pdf wth text in the header & footer and timevalues in between. I want to eliminate header and footer text. Text in main body contans names of individuals and series of timestamps relevant to each. After elimination I will convert timestamps which are cuurently strings to datetime, and then to seonds. (these are just some sports related runs so using seocnds for close comparison) And then perform required analysis. A bit roundabbout. This code will serve as template code for future imports too. I can always clean up in excel and then bring into MATLAB but I want to keep it all in one application. Plus excel crashes with large datasets.
Ill accpet your answer towards furture reference; might encounter the scenario you indicate. Thanks.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by