From: Walter Roberson on 3 May 2010 21:21 roya olyazadeh wrote: > I read this . I dont want to creat index. please just tell me how can I > add string to an integer matrix ????????????????? That is impossible in Matlab. Numeric matrices in Matlab can never contain character strings. >> from=[1 ;2 ;4; 6; 7; 8 ] Possibly what you are looking for is: >> num2str(from,'x%d') ans = x1 x2 x4 x6 x7 x8
From: roya olyazadeh on 3 May 2010 22:54 Walter Roberson <roberson(a)hushmail.com> wrote in message <hrnsq9$1va$2(a)canopus.cc.umanitoba.ca>... > roya olyazadeh wrote: > > > I read this . I dont want to creat index. please just tell me how can I > > add string to an integer matrix ????????????????? > > That is impossible in Matlab. Numeric matrices in Matlab can never contain > character strings. > > >> from=[1 ;2 ;4; 6; 7; 8 ] > > Possibly what you are looking for is: > > from= num2str(from,'x%d') > ans = > x1 > x2 > x4 > x6 > x7 > x8 Tnx but it is not my answer.. I am not looking to display it in matlab.. I need to do computation on it.. This way give me a matrix (2 6) I need (1 6) When I call 'from(1,1)' I need this answer 'x1' but here : from(1,1) = x and from(1,2)=1
From: roya olyazadeh on 3 May 2010 22:57 "us " <us(a)neurol.unizh.ch> wrote in message <hrmfct$rhf$1(a)fred.mathworks.com>... > "roya olyazadeh" > > > This error occurred after running > > > > Too many inputs. > > > > Error in ==> secndcor at 13 > > v=cellfun(@(x) sscanf(x,tmpl{i,3}),s(ix),'uni',false); > > > > and one thing , file size is changeable. sometimes maybe 100 lines . sometimes they > > are not in order like this : > > D 1 2 122.286 0.002 > > A 1 2 5 35 17 32.00 3.0 > > C 1 1000.000000 1000.000000 ! > > D 1 3 190.522 0.002 > > C 4 878.926000 1021.071000 ! ! > > > > What is the solution ? > > which ML version do you have(?)... > can you upgrade(?)... > note: the order of your character tags does not matter... > > us I use matlab 7 I have another question.. Can you tell me how can I add string to a matrix. For this example I have this matrix : from=[1 ;2 ;4; 6; 7; 8 ] Now I want to add x to them so I have from=[x1;x2;x4;x6;x7;x8] when I add them, Matlab gave me answers in numbers not in string like this from=[x1;x2;x4;x6;x7;x8] tnx againt for your help.
From: Walter Roberson on 3 May 2010 23:25 roya olyazadeh wrote: > Tnx but it is not my answer.. I am not looking to display it in matlab.. > I need to do computation on it.. This way give me a matrix (2 6) I > need (1 6) When I call 'from(1,1)' I need this answer 'x1' but here : > from(1,1) = x and from(1,2)=1 I believe you will have to write your own data class in order to implement that. Matlab strings are arrays, and it is not possible with the normal Matlab data types to store a character string in such a way that the entire string can be referenced by an index in parenthesis. Unless you create your own data class with its own subsref method, in Matlab, from(1,1) cannot be an entire string. If you are willing to modify your requirements slightly, then you might find the following to be satisfactory: from = cellstr(num2str(from,'x%d')); After that, from(1,1) will NOT be 'x1', but it will be {'x1'} -- a 1 x 1 cell array that has inside it the string 'x1' . To get directly to that string, you can code from{1,1} which will be 'x1' . Notice the use of {} instead of () . Indexing with {} *can* give you an entire string back, but indexing with () *cannot* give you an entire string back.
From: roya olyazadeh on 4 May 2010 00:58
> > If you are willing to modify your requirements slightly, then you might > find the following to be satisfactory: > > from = cellstr(num2str(from,'x%d')); > > After that, from(1,1) will NOT be 'x1', but it will be {'x1'} -- a 1 x 1 > cell array that has inside it the string 'x1' . To get directly to that > string, you can code from{1,1} which will be 'x1' . Notice the use of {} > instead of () . Indexing with {} *can* give you an entire string back, > but indexing with () *cannot* give you an entire string back. Yes That 's true It worked . thank you . syms a b c d L01=((c-a)^2+(d-b)^2)^0.5; FX=cellstr(num2str(from,'x%d')); FY=cellstr(num2str(from,'y%d')); TX=cellstr(num2str(to,'x%d')); TY=cellstr(num2str(to,'y%d')); for i= 1 : nd L0(i)=subs(L01,[a b c d ],[FX(i,1) FY(i,1) TX(i,1) TY(i,1)]); end After this I will use 'diff' for example : diff(L0,x1) and then do my computation LSE |