Error in string operation

3 次查看(过去 30 天)
klb
klb 2020-7-4
评论: klb 2020-7-4
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.

采纳的回答

Steven Lord
Steven Lord 2020-7-4
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 个评论
klb
klb 2020-7-4
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by