How to use "extractBetween" function with FEVAL in TLC code in R2016b?

7 vues (au cours des 30 derniers jours)
I would like to use the "extractBetween" function in TLC code in R2016b as follows:
%assign test = FEVAL("extractBetween","ABCDSD","A","D")
Doing this I see the error:
"Only double and character arrays can be converted from MATLAB to TLC. This can occur if the MATLAB function does not return a value (see %matlab)"
While using similar other functions in TLC files they are working fine, e.g.
FEVAL("eraseBetween",outport_1,"<",">")
How to workaround this error message?

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 17 Fév 2023
The issue is currently caused by the behavior of the extractBetween function in R2016b which outputs a string even if you input only character array inputs.
This behavior was changed to the expected one in R2017a, where the input data type is equal to the output data type. That means in this release and later the below workaround is not needed and the error is not shown.
As a workaround, you need a function which will output a character array instead of a string in R2016b, if you cannot upgrade your MATLAB release.
There a several possible solutions, for example:
Use the extractBetween function, with a wrapper function which could look like the following:
function [ newStr ] = extractBetweenTLC(str,startPat,endPat)
newStr = extractBetween(str,startPat,endPat);
newStr = char(newStr);
end
In the TLC file you can the use it as follows:
%assign test2 = FEVAL("extractBetweenTLC","ABCDSD","A","D")
Another solution would be to use regular expressions instead of the extractBetween function:\n
%assign test = FEVAL("regexp","ABCDSD","(?<=A)(.*?)(?=D)","match","once")

Plus de réponses (0)

Produits


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by