Prev: Standalone application
Next: Image Construction
From: John on 28 Jun 2010 18:39 how do I use STR2NUM to turn a 10000x6 character array that looks like: #NAME? #NAME? #NAME? : : #NAME? into a 10000x1 Matrix that looks like: NaN NaN NaN : : NaN Thanks for the help!
From: Matt Fig on 28 Jun 2010 18:52 Do you want the numeric value NaN? Why not just create a nan array the same size as your character array? G = repmat('#NAME?',10,1); % A character array G = nan(size(G,1),1)
From: dpb on 28 Jun 2010 18:56 John wrote: > how do I use STR2NUM to turn a 10000x6 character array that looks like: > > #NAME? > #NAME? > #NAME? > : > : > #NAME? > > into a 10000x1 Matrix that looks like: > > NaN > NaN > NaN > : > : > NaN > > > Thanks for the help! Can't mix numeric and the character ":" in a matrix, best you could do is a cell array or character substitution in the existing array. Unless, of course you convert the ":" to some other numeric value, too. Then, str2double() would work I think ... no, it shortcircuits after first NaN result. This would do as a kluge, maybe... b=[]; for idx=1:size(a,1) if strcmp(a(idx),':') b(idx)=0 else b(idx)=str2double(idx); end end W/ the newer bsxfun or cellfun one could undoubtedly do more than can w/ my old release to vectorize something --
|
Pages: 1 Prev: Standalone application Next: Image Construction |