Code Comments
Programming Forum and web based access to our favorite programming groups.Dear friends, Is there any way to limit the decimals? Thank you
Post Follow-up to this messageThanks!!! But i have to use it before i use each variable or i can put it in some way that will be used for all? Dan Pearce wrote: > > > see > > help format > > and look at long and short
Post Follow-up to this messageI'm guessing you are looking for something like 'int', 'double', 'float' etc... As it says at the top of the 'help format' comment "All computations in MATLAB are done in double precision. FORMAT may be used to switch between different output" so there isn't anything you will be able to change other than the way the results of calculation are displayed or saved. Why were you looking to change it? Maybe we can help you more if we know a bit more about your problem
Post Follow-up to this messageThe problem is that i'm making a program to calculate the transfer function and the Zin of a subscriber loop... i have to make a lot of operations and some people wants it with a lot of precision (a lot of more operations..). If i do this, the pc needs a lot of ram and goes very slow. I want to try to reduce the decimals because maybe in this way i make that the program runs faster... Thanks a lot and sorry for my bad english ! Dan Pearce wrote: > > > I'm guessing you are looking for something like 'int', 'double', > 'float' etc... > > As it says at the top of the 'help format' comment > > "All computations in MATLAB are done in double precision. > FORMAT may be used to switch between different output" > > so there isn't anything you will be able to change other than the > way > the results of calculation are displayed or saved. > > Why were you looking to change it? Maybe we can help you more if we > know a bit more about your problem
Post Follow-up to this messageObviously I don't know your problem, but I am not sure how you can have "some people want it with a lot of precision" as a problem and then "try to reduce the decimals" as a possible resolution. It seems a little counter intuitive to me. If you have problems with speed then you should be looking to vectorise as much of your code as possible, or even to try and split your operations down so that they do not demand so much RAM at one time.
Post Follow-up to this messagebru wrote: > > > The problem is that i'm making a program to calculate the transfer > function and the Zin of a subscriber loop... i have to make a lot > of > operations and some people wants it with a lot of precision (a lot > of > more operations..). If i do this, the pc needs a lot of ram and > goes > very slow. I want to try to reduce the decimals because maybe in > this > way i make that the program runs faster... > Thanks a lot and sorry for my bad english ! > > Dan Pearce wrote: 'double', the if > we Just put, format short e %for 5 digit precision or format long e %for 15 digit precision at the top of your m-file(program).
Post Follow-up to this messageAditya vedantam wrote: > > > bru wrote: > transfer lot > lot in > 'double', than > the more > if > > Just put, > format short e %for 5 digit precision > or > format long e %for 15 digit precision > at the top of your m-file(program). Yeah but,"trying to reduce the decimals" is no way to increase computational speed.Try vectorizing the code.
Post Follow-up to this message> Aditya vedantam wrote: > Just put, > format short e %for 5 digit precision > or > format long e %for 15 digit precision > at the top of your m-file(program). This wont speed up the code. All computations in MATLAB are done in double precision! This only changes the accuracy to which the results displayed
Post Follow-up to this messageAditya vedantam wrote: > Yeah but,"trying to reduce the decimals" is no way to increase > computational speed.Try vectorizing the code. How can i do this? ^o)
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.