Prev: Have some question about Instrument Control Toolbox from Simulink
Next: Remove certain spaces of a char matrix
From: Oscar on 26 May 2010 19:02 Hello. I have a character matrix like this: matrix = a 1 v1 v3 c2 c1 a 4 a 2 a 5 a 6 a 2 v3 v2 c5 c1 a 1 a 3 a10 a 5 a 3 v2 v4 c4 c1 a 2 a 4 a 8 a10 a 4 v4 v1 c3 c1 a 3 a 1 a 6 a 8 a 5 v5 v3 c5 c2 a 7 a 1 a 2 a12 a 6 v1 v6 c3 c2 a 1 a 7 a 9 a 4 a 7 v6 v5 c6 c2 a 6 a 5 a12 a 9 a 8 v4 v7 c4 c3 a 4 a 9 a11 a 3 a 9 v7 v6 c6 c3 a 8 a 6 a 7 a11 a10 v2 v8 c5 c4 a 3 a11 a12 a 2 a11 v8 v7 c6 c4 a10 a 8 a 9 a12 a12 v5 v8 c6 c5 a 5 a10 a11 a 7 As you see, some elements of the "first column" (actually will be the three first columns because "matrix" is a 12x47 char) and other "columns" (6 to 10) have a space between 'a' and 'number' where number can be 1, 2, 3, 4, etc... Does anyone know any function to delete certain characters located in a matrix? If there's no mechanism to do this, i would think in redifining the matrix... Now, my matrix has been defined following this procedure: n_ARISTASf=[1:1:12]'; ARISTASf_str=strcat('a',[1:1:12]'); %I should have that ARISTASf_str=[a1;a2....a9,a10] but i actually have %[a 1;a 2....a 9,a10] -> the existence of numbers with two digits creates %a non-desirable space in some of the componentes of the vector %..... Following variables inside num2str() are double column vectors IZQf_str=strcat('c',num2str(izq_prima)); DERf_str=strcat('c',num2str(der_prima)); DESf_str=strcat('v',num2str(DESDf)); HACIAf_str=strcat('v',num2str(HACIAf)); pder_prima_str=strcat('a',num2str(pder_prima)); sder_prima_str=strcat('a',num2str(sder_prima)); pizq_prima_str=strcat('a',num2str(pizq_prima)); sizq_prima_str=strcat('a',num2str(sizq_prima)); blanks=[]; for i=1:size(ARISTASf_str,1) huecos=vertcat(blanks,' '); end matrix=horzcat(ARISTASf_str,blanks,DESf_str,blanks,HACIAf_str,blanks,IZQf_str,blanks,DERf_str,blanks,pder_prima_str,blanks,sder_prima_str,blanks,pizq_prima_str,blanks,sizq_prima_str); That is to say, i do a horzcat of column vectors, that i've obtained using strcat('letter',num2str(vector of doubles)). In conclusion, i want to remove the blank spaces that appear after certain 'a' characters. |