f



left, right?

What function returns some number of characters on the right or left
of a string? i.e. if I have the string 'filename', is there a command
like Left('filename',4) = file? Thanks.
0
nospam21 (19047)
2/9/2007 9:23:46 PM
comp.soft-sys.matlab 211266 articles. 23 followers. lunamoonmoon (257) is leader. Post Follow

3 Replies
622 Views

Similar Articles

[PageSpeed] 50

asdd12 wrote:
>
>
> What function returns some number of characters on the right or
> left
> of a string? i.e. if I have the string 'filename', is there a
> command
> like Left('filename',4) = file? Thanks.

>> f='filename'

f =

filename

>> f(1:4)

ans =

file
0
PT_Ken1 (193)
2/9/2007 9:53:27 PM
In article <ef4d6a8.-1@webcrossing.raydaftYaTP>, nospam@nospam.com 
says...
> What function returns some number of characters on the right or left
> of a string? i.e. if I have the string 'filename', is there a command
> like Left('filename',4) = file? Thanks.
> 

f = 'filename'
left4 = f(1:4)

Read "Getting Started with MATLAB"

--Loren
http://blogs.mathworks.com/loren/
0
loren5358 (941)
2/9/2007 10:01:30 PM
asdd12:
<SNIP a leftist...

> What function returns some number of characters on the right or
left of a string

one of the many solutions

% the outset
     s='1234-5678';
     nl=4;
% the engine
if nl <= length(s)
     s=s(1:nl);
% -or- depending upton the size of <s> and <nl>
% s(nl+1:end)='';
end
% the result
     s

us
0
us1 (8051)
2/10/2007 3:27:42 AM
Reply: