%x not working in textscan

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

%x not working in textscan

dev1990
This post was updated on .
Hello all,

 i am running Octave 5.2 in Windows 10. I have found that %x as a conversion
specifier has not yet been implemented. Checked textscan help also, no mention of %x for Hex numbers.

Below are my snippet :


>> fid=fopen('sample.txt');
>> A=textscan(fid,'%x');
error: textscan: '%x' is not a valid format specifier
>> A=textscan(fid,'%s');
>> A
A =
{
  [1,1] =
  {
    [1,1] = 0x004de2ea
    [2,1] = 0x006df1f4
  }

}

>> fclose(fid)
ans = 0




--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: %x not working in textscan

Tony Richardson-4
On Sun, Apr 19, 2020 at 11:07 AM dev1990 <[hidden email]> wrote:
Hello all,

 i am running Octave 5.2 in Windows 10. I have found that %x as a conversion
specifier has not yet been implemented. Check textscan help also.  Below are
my snippet :


>> fid=fopen('sample.txt');
>> A=textscan(fid,'%x');
error: textscan: '%x' is not a valid format specifier
>> A=textscan(fid,'%s');
>> A
A =
{
  [1,1] =
  {
    [1,1] = 0x004de2ea
    [2,1] = 0x006df1f4
  }

}

>> fclose(fid)
ans = 0




--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html

I'm not sure if you are looking for an alternate method or are just asking for this to be implemented in textscan, 
but another way to read the numbers in would be to use fscanf:

A = fscanf(fid, '%x');

This would read the numbers into a matrix instead of a cell array.

Tony