Prev: How to make list out of my outdata
Next: Simulink
From: us on 13 May 2010 14:30 "subbu " <ysrhcu(a)yahoo.com> wrote in message <hshenl$5mm$1(a)fred.mathworks.com>... > "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message <hsfs8o$19p$1(a)fred.mathworks.com>... > > "subbu " <ysrhcu(a)yahoo.com> wrote in message <hsfod0$nhj$1(a)fred.mathworks.com>... > > > I have a single row matrix with 121 columns. I want to make a new matrix with first 10 elements as 1st row, second 10 elements as 2nd row,.......12 rows and last row has a single element. > > > > > > is there a command to do this? > > =============== > > > > No. All rows of a matrix in MATLAB have to have the same number of elements. You cannot have a matrix with 10 elements in some rows and a single element in the final row. > > Hi, > It will still be a 21x121 matrix. But i need this matrix as an input to other code that im running, and that code accepts the file only if it is in "10f10.3" format. > Thats why i need to decompose this matrix. > > doing it manually 121 times is a bit cumbersome. It will be good to know if there is any command that can do this job. > > cheers > thanks in advance instead of whining, did you look at and try what you were told before(?)... us
From: Steven Lord on 13 May 2010 17:23 "subbu " <ysrhcu(a)yahoo.com> wrote in message news:hshenl$5mm$1(a)fred.mathworks.com... > "Matt J " <mattjacREMOVE(a)THISieee.spam> wrote in message > <hsfs8o$19p$1(a)fred.mathworks.com>... >> "subbu " <ysrhcu(a)yahoo.com> wrote in message >> <hsfod0$nhj$1(a)fred.mathworks.com>... >> > I have a single row matrix with 121 columns. I want to make a new >> > matrix with first 10 elements as 1st row, second 10 elements as 2nd >> > row,.......12 rows and last row has a single element. >> > >> > is there a command to do this? >> =============== >> >> No. All rows of a matrix in MATLAB have to have the same number of >> elements. You cannot have a matrix with 10 elements in some rows and a >> single element in the final row. > > Hi, > It will still be a 21x121 matrix. That is not consistent with what you said above, and I quote: "I want to make a new matrix with first 10 elements as 1st row, second 10 elements as 2nd row, ..." Matt is correct; you cannot have a "jagged" array with any row having a different number of columns than any other (or vice versa.) Unless ... did you mean you want to do something like this? x = 1:7; y = [1 2 3 0 0 0 0; 0 0 0 4 5 6 0; 0 0 0 0 0 0 7] > But i need this matrix as an input to other code that im running, and > that code accepts the file only if it is in "10f10.3" format. So if I understand this correctly, you don't actually want to convert your 1-by-121 vector into a new _matrix_, you want to _write it to a file in a specific format_. That's a completely different question. Use the low-level file I/O functions (FOPEN, FPRINTF, FCLOSE) listed in "help iofun" to do so. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: TideMan on 13 May 2010 17:44 On May 14, 9:23 am, "Steven Lord" <sl...(a)mathworks.com> wrote: > "subbu " <ysr...(a)yahoo.com> wrote in message > > news:hshenl$5mm$1(a)fred.mathworks.com... > > > > > "Matt J " <mattjacREM...(a)THISieee.spam> wrote in message > > <hsfs8o$19...(a)fred.mathworks.com>... > >> "subbu " <ysr...(a)yahoo.com> wrote in message > >> <hsfod0$nh...(a)fred.mathworks.com>... > >> > I have a single row matrix with 121 columns. I want to make a new > >> > matrix with first 10 elements as 1st row, second 10 elements as 2nd > >> > row,.......12 rows and last row has a single element. > > >> > is there a command to do this? > >> =============== > > >> No. All rows of a matrix in MATLAB have to have the same number of > >> elements. You cannot have a matrix with 10 elements in some rows and a > >> single element in the final row. > > > Hi, > > It will still be a 21x121 matrix. > > That is not consistent with what you said above, and I quote: > > "I want to make a new matrix with first 10 elements as 1st row, second 10 > elements as 2nd row, ..." > > Matt is correct; you cannot have a "jagged" array with any row having a > different number of columns than any other (or vice versa.) > > Unless ... did you mean you want to do something like this? > > x = 1:7; > y = [1 2 3 0 0 0 0; 0 0 0 4 5 6 0; 0 0 0 0 0 0 7] > > > But i need this matrix as an input to other code that im running, and > > that code accepts the file only if it is in "10f10.3" format. > > So if I understand this correctly, you don't actually want to convert your > 1-by-121 vector into a new _matrix_, you want to _write it to a file in a > specific format_. That's a completely different question. Use the > low-level file I/O functions (FOPEN, FPRINTF, FCLOSE) listed in "help iofun" > to do so. > > -- > Steve Lord > sl...(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ:http://matlabwiki.mathworks.com/MATLAB_FAQ Yes, I've already told him how to do it in another thread using fprintf. He's opening multiple threads on the same problem, but not taking any notice of any of the answers. Maybe he's winding us up? What he really needs is a good flaming. Any volunteers?
From: Mark Shore on 13 May 2010 18:08 > Yes, I've already told him how to do it in another thread using > fprintf. > He's opening multiple threads on the same problem, but not taking any > notice of any of the answers. > > Maybe he's winding us up? > What he really needs is a good flaming. > Any volunteers? Obtaining a statistically significant number of answers and picking the most common one may save the OP the heartbreak and pain of actually trying other methods out - or worse yet - learning MATLAB.
From: Steven Lord on 14 May 2010 10:21
"TideMan" <mulgor(a)gmail.com> wrote in message news:243cdcd0-369b-47eb-b0a8-510912c7565b(a)k17g2000pro.googlegroups.com... On May 14, 9:23 am, "Steven Lord" <sl...(a)mathworks.com> wrote: > "subbu " <ysr...(a)yahoo.com> wrote in message *snip* > Yes, I've already told him how to do it in another thread using > fprintf. > He's opening multiple threads on the same problem, but not taking any > notice of any of the answers. Sadly, that's not as rare a situation as it should be. On any newsgroup. > Maybe he's winding us up? > What he really needs is a good flaming. > Any volunteers? Believe me, that behavior is MINOR compared to some of the stuff I've seen in other newsgroups I have read. For example, if you think you can take it, search Google Groups for the two words "JSH" and "Fermat". There's nobody even CLOSE to that on CSSM (thankfully.) I've been thinking for a while now that we need some sort of new poster guidelines for CSSM that we can point new posters to, to encourage good behavior and good posting habits. [It wouldn't guarantee that new posters would abide by them, but if we describe it as "how to increase the chances your question will be answered" that might prove compelling enough.] Maybe I'll take a first pass at that this weekend and post it next week for feedback. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ |