I thought I just answered this question a few minutes ago. Here it is again!!
str = '24.42x3 - 0.87x2 + x + 489(*&'; %# Your sample string
alphaStr = str(isstrprop(str,'alpha')); %# Get the alphabetic characters
digitStr = str(isstrprop(str,'digit')); %# Get the numeric characters
otherStr = str(~isstrprop(str,'alphanum')); %# Get everything that isn't an
%# alphanumeric character
str = '24.42x3 - 0.87x2 + x + 489'
idx = regexp(str,'\d+')
nums = regexp(str,'\d+','match')
%%To get the numbers out, as opposed to strings, use:
str2num(nums{1})
"Mirage " <miragel@uvic.ca> wrote in message <k5p4ad$11d$1@newscl01ah.mathworks.com>...
> Hi,
>
> I'm would like to know if there is a matlab function that will extract the coefficients from a differential equation.
>
> E.g.
> y = 24.42x3 - 0.87x2 + x + 489
>
> I want to extract the numbers 24.42, -0.87, 1, and 489.
>
> Thanks
str = '24.42x3 - 0.87x2 + x + 489(*&'; %# Your sample string
alphaStr = str(isstrprop(str,'alpha')); %# Get the alphabetic characters
digitStr = str(isstrprop(str,'digit')); %# Get the numeric characters
otherStr = str(~isstrprop(str,'alphanum')); %# Get everything that isn't an
%# alphanumeric character
str = '24.42x3 - 0.87x2 + x + 489'
idx = regexp(str,'\d+')
nums = regexp(str,'\d+','match')
%%To get the numbers out, as opposed to strings, use:
str2num(nums{1})
"Mirage " <miragel@uvic.ca> wrote in message <k5p4ad$11d$1@newscl01ah.mathworks.com>...
> Hi,
>
> I'm would like to know if there is a matlab function that will extract the coefficients from a differential equation.
>
> E.g.
> y = 24.42x3 - 0.87x2 + x + 489
>
> I want to extract the numbers 24.42, -0.87, 1, and 489.
>
> Thanks