سؤال

I have a code that i'm trying to run in matlab, it gives an error in textscan function as it can't split a string on a delimiter, although i'm sure the code works on other versions of matlab (on other computer)

>> a='ahmed;mohamed'

a =

ahmed;mohamed

>> b = textscan(a, '%s;%s', 'Delimiter', ';')

b = 

    {1x1 cell}    {0x1 cell}

>> b{1}

ans = 

    'ahmed'

>> b{2}

ans = 

   Empty cell array: 0-by-1

Can some one explain Why this is happening ? is there a recent change in textscan function ? i'm using matlab 2013

هل كانت مفيدة؟

المحلول

This works:

str = 'ahmed;mohamed';
C = textscan(str, '%s', 'Delimiter',';', 'CollectOutput',true);
C = C{1};

with:

>> C
C = 
    'ahmed'
    'mohamed'
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top