Suppose I have a simple text file named "test.txt" of the format below
A=-1.1,2.2,-3.3,4.4B
My intention is to extract data -1.1, 2.2, -3.3 and 4.4 in Matlab from the text file.
How could I do that?
Ps: Note that the data is between a string "A =" and "B" and is separated by a comma.
I managed to extract the first data with the code below.
buffer = fileread('test.txt');
search = 'A=';
local = strfind(buffer, search);
value = sscanf(buffer(local(1,1)+numel(search):end), '%f', 1);
However, I'm not sure how to get the other values from the list that end in the string "B"
textscan? It is designed for handling inputs with specific formats like those. For example, you would use something liketextscan(string,"%*c %*c %f %f %f %f %*c", 'delimiter', ',').