Prev: Signal/Spectrum from Wigner-Ville or other time-frequency distribution
Next: is there a way to automatically read in all the sheet names in an Excel book?
From: ben harper on 22 Jan 2010 16:43 i know it's a very simple questiın, sorry. i have a variable as variable1 = 1.0e+003 * 0.3000 9.3000 -0.0063 9.3063 i want matlab show this as: variable1 = 300.0 9300.0 -6.3 9306.3 using "format" function doesn't solve right?..
From: Steven Lord on 22 Jan 2010 17:13 "ben harper" <controlusc(a)gmail.com> wrote in message news:hjd65p$72a$1(a)fred.mathworks.com... >i know it's a very simple questiın, sorry. > > i have a variable as > variable1 = > > 1.0e+003 * > > 0.3000 9.3000 -0.0063 9.3063 > > i want matlab show this as: > > variable1 = > > 300.0 9300.0 -6.3 9306.3 > > using "format" function doesn't solve right?.. No, FORMAT will not format this variable exactly like that -- in order to do that, you will need to SPRINTF the variable when you want to display it like that. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: ben harper on 22 Jan 2010 17:28 "Steven Lord" <slord(a)mathworks.com> wrote in message <hjd7un$oi$1(a)fred.mathworks.com>... > > "ben harper" <controlusc(a)gmail.com> wrote in message > news:hjd65p$72a$1(a)fred.mathworks.com... > >i know it's a very simple questiın, sorry. > > > > i have a variable as > > variable1 = > > > > 1.0e+003 * > > > > 0.3000 9.3000 -0.0063 9.3063 > > > > i want matlab show this as: > > > > variable1 = > > > > 300.0 9300.0 -6.3 9306.3 > > > > using "format" function doesn't solve right?.. > > No, FORMAT will not format this variable exactly like that -- in order to do > that, you will need to SPRINTF the variable when you want to display it like > that. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > hello, when i make variable1 = 1.0e+003 * 0.3000 9.3000 -0.0063 9.3063 sprintf('%6.1f',variable1) the answer is ans = 300.09300.0 -6.39306.3 is it possible to show in vector/matrix form?
From: Walter Roberson on 22 Jan 2010 18:13 ben harper wrote: > when i make > > variable1 = > 1.0e+003 * > 0.3000 9.3000 -0.0063 9.3063 > sprintf('%6.1f',variable1) > the answer is > ans = > 300.09300.0 -6.39306.3 > is it possible to show in vector/matrix form? sprintf([repmat('%6.1f ',1,length(variable1)-1), '%6.1f'], variable1) Notice the space after the f and before the quote in the first instance of %6.1 . If you do not mind there being a trailing space at the end of the line, you can simplify the whole thing to sprintf('%6.1f ', variable1)
From: Edward D. on 22 Jan 2010 18:41
Walter Roberson <roberson(a)hushmail.com> wrote in message <hjdbri$3g0$1(a)canopus.cc.umanitoba.ca>... > ben harper wrote: > > > when i make > > > > variable1 = > > 1.0e+003 * > > 0.3000 9.3000 -0.0063 9.3063 > > sprintf('%6.1f',variable1) > > > the answer is > > ans = > > 300.09300.0 -6.39306.3 > > > is it possible to show in vector/matrix form? > > sprintf([repmat('%6.1f ',1,length(variable1)-1), '%6.1f'], variable1) > > Notice the space after the f and before the quote in the first instance of %6.1 . > > If you do not mind there being a trailing space at the end of the line, you > can simplify the whole thing to > > sprintf('%6.1f ', variable1) ------------------ format short g will do the trick i believe |