[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Suppress eval out put in "units.m"
From: |
Andy Buckle |
Subject: |
Re: Suppress eval out put in "units.m" |
Date: |
Fri, 20 Apr 2012 21:43:51 +0100 |
On 20 April 2012 20:58, Mech.Mon <address@hidden> wrote:
> Hello all,
>
> I modified units.m to work on my system, now it works but the "eval ("
> statement always prints now. Any way to suppress this output? For example:
>
> 14:49:04 :35> z= units("kg/m^3", "lb/ft^3", [996.2018,997.2018,998.2018])
> y =
>
> 62.191 62.253 62.316
>
> z =
>
> 62.191 62.253 62.316
>
> 14:49:18 :36>
>
>
>
> function y = units(fromUnit, toUnit, x)
> if 2 > nargin || 3 < nargin || !ischar(fromUnit) || !ischar(toUnit)
> usage('units(fromUnit, toUnit [, x])')
> endif
> [status, rawoutput] = system(sprintf('C:\\GnuWin32\\bin\\units "%s"
> "%s"', fromUnit, toUnit), 1);
> (0 == status) || error([rawoutput,
> 'Verify that GNU units is installed in the current path.']);
>
> i = index(rawoutput, "*");
> j = index(rawoutput, "\n") - 1;
> i && (i < j) || error('parsing units output "%s"', rawoutput);
>
> exist("x", "var") || (x = 1);
>
> ###eval(['y=x', rawoutput(i:j), ';']);<---------Throws parse error
> eval(['y=x', rawoutput(i:j)]);#works but displays "y = ...."
> endfunction
eval(['y=x;', rawoutput(i:j)]);
--
/* andy buckle */