help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HEPL FOR A FUNCTION


From: Juan Pablo Carbajal
Subject: Re: HEPL FOR A FUNCTION
Date: Thu, 19 Apr 2012 13:22:36 +0200

On Thu, Apr 19, 2012 at 1:07 PM, CARMEN SANCHEZ <address@hidden> wrote:
> Hi Doug:
>
> Sorry, but I cannot understand to you.
>
> I have this:
>
> clear all;
>
> A=[-0,195966, -0,397014, -0,538551, -0,954502;
> -0,021981,      0,387760,   -0,593141,   -0,240908;
> -0,195130,      0,013832,   -0,686614,   -0,901565;
> 0,134872,      0,711619,   -0,339303,      0,440442];
> b=[-0,0129656;
> 0,6601410;
> 0,0694383;
> 0,3373380];
> B  =  [A,
> b];
> rank
> (A)
> rank (b)
> rank (B)
> [R,  K]  =   rref
> (B)
>
> I have calculate the matrix and now I want to calculate the same but now I
> just want both matrix with 2 decimals like this:
>
> clear all;
> A=[-0,19, -0,39, -0,53, -0,95; ......
>
> b=[-0,012;
> ......
>
> How can I do it automatically?
>
> thank you very much for your help.
>
> Best regards,
>
> Javier M. (from Spain)
>
>
> ________________________________
> Date: Thu, 19 Apr 2012 06:58:35 -0400
> Subject: Re: HEPL FOR A FUNCTION
> From: address@hidden
> To: address@hidden
> CC: address@hidden
>
>
>
>
> On Thu, Apr 19, 2012 at 6:37 AM, CARMEN SANCHEZ <address@hidden>
> wrote:
>
> Good morning:
>
> I am using octave to resolve a matrix problem.
>
> I have this matrix:
>
> A=[-0,195966, -0,397014, -0,538551, -0,954502;
> -0,021981,      0,387760,   -0,593141,   -0,240908;
> -0,195130,      0,013832,   -0,686614,   -0,901565;
> 0,134872,      0,711619,   -0,339303,      0,440442];
>
> Is there any octave function to reduce decimals to just only 2 decimals
> without erase them manually?
>
> Best regards,
>
> Javier M.
>
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>
>
>
>
> try
> output_precision(0)
>
>
>
> --
> DAS
>
> https://linuxcounter.net/user/206392.html
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>

The command
 output_precision(n)
shows you the numeric output up to precision n.
However your numbers are still internally represented with the whole precision

If you want to limit your numbers to a given precision you can use the
function truncate from the miscellaneous package (which is not
released yet, you must get it from svn)
http://octave.svn.sf.net/viewvc/octave/trunk/octave-forge/main/miscellaneous/inst/truncate.m?view=log

the function is quite simple. so you can do it directly in the command line:
A_trunc = fix(A*1e2)*1e-2

Should put truncate all your numbers to two decimal places. If you
want them rounded instead of truncated use function "round" instead of
"fix"

I hope this helps sou.


-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]