Code covered by the BSD License  

Highlights from
gunits

5.0

5.0 | 1 rating Rate this file 3 Downloads (last 30 days) File Size: 2.25 KB File ID: #28613
image thumbnail

gunits

by Sean de

 

01 Sep 2010

Function that converts units using Google

| Watch this File

File Information
Description

help gunits

%Function to convert units using Google
%SCd 09/01/2010
%
%gunits searches using the Google convention e.g: '3ft to in'
%
%Input Arguments:
% -before: string with number and unit such as:
% '3ft', '17c','17lbf/in^2', '3 ft*lbf'
% -after: unit you wish to convert such as: (respectively)
% 'mm', 'f', 'N/ft^2','Newton*m'
%
% NOTE1: Google can be picky with the input. It's recommended
% to spell everything out and fill in multiplication/division/powers
% if you're having issues. Example:
%
% >>gunits('3psi','psf')
% ans = '<i>3 psi</i>' %if outNum was called; an error would've been produced
%
% >>gunits('3lbf/in^2','lbf/ft^2')
% ans = 3 (lbf / (in^2)) = 432 lbf / (ft^2)
%
% NOTE2: The units should be distinguishable with spaces removed e.g:
% 'lbf ft' becomes 'lbfft' which is not a unit. To fix use 'lbf*ft'
%
%Output Arguments:
% -outStr: string with the conversion
% -outNum: numeric value of answer (only if asked for)
%
%NOTE/DISCLAIMER:
% The algorithm used for retrieving the string is based solely on Google's
% web format. As (unfortunately!), I do not own or control Google, their
% format is subject to change, which could nullify the results of this program.
% Please let me know if this happens.
%

MATLAB release MATLAB 7.9 (2009b)
Other requirements Internet Connection
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
02 Nov 2010 paul william

FANTASTIC. you are a genius sir. never thought we could use matlab for such use.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
units Sean de 01 Sep 2010 11:01:02
google Sean de 01 Sep 2010 11:01:02
conversion Sean de 01 Sep 2010 11:01:02
convert Sean de 01 Sep 2010 11:01:02

Contact us at files@mathworks.com