From: carl on 14 Apr 2010 19:23 I need to convert the double elements in a vector to string elements. I have tried: v = [23 12 34 34 12]; v_str0 = num2mstr(v); v_str0(1) ans = [ v_str1 = num2str(v); v_str1(1); ans = 2 what I want is: v_str1(1); ans = 23 How do I convert all digits for each element into string in v?
From: Matt Fig on 14 Apr 2010 19:33 "carl" <carl@.com> wrote in message <4bc64e76$0$285$14726298(a)news.sunsite.dk>... > I need to convert the double elements in a vector to string elements. I have > tried: > > v = [23 12 34 34 12]; > v_str0 = num2mstr(v); > v_str0(1) > > ans = > > [ > > > > v_str1 = num2str(v); > v_str1(1); > ans = > > 2 > > > > what I want is: > > v_str1(1); > ans = > > 23 > > > How do I convert all digits for each element into string in v? You should probably use cell arrays to get what you want here. One approach: % Data v = [23 12 34 34 12]; % Engine v_str0 = regexp(num2str(v),'\d+','match'); v_str0{1} %{ ans = 23 %}
|
Pages: 1 Prev: Help with Mexnc define variable Next: repmat without tiling? |