help-octave
[Top][All Lists]
Advanced

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

Re: Bizarre Error


From: pand9613
Subject: Re: Bizarre Error
Date: Thu, 13 Feb 2003 09:38:30 +1100
User-agent: Internet Messaging Program (IMP) 3.0

Thanks for the suggestion. I only dicovered the existence of the menu function 
after i had already written most 
my code. Rest assured i will use it in future.
I made the changes you recommended but the results were unsuccessful. The code 
works and works fine...the user can enter in any value EXCEPT a string 
containing letters prefixed by numbers. It just doesn't make sense that 
something which does not redefine any variables could cause an error in code 
that runs correctly otherwise. I will email you the code and a sample of 
the 'Materials' directory so that you can run it yourself and at least see the 
error...or that my version/installation of octave is at fault.
If anyone wants to take the time to look at this it would be much appreciated. 
Just copy *.m to a directory and *.mtl to a subdirectory 'Materials' (or 
edit the code to put it where you want). Then run viewmat.m. Note: all problems 
lie in getmatv2.m, i only include viewmat to give some scope to the aim of the 
code.
To test it try the various menu options, 'b', 'e', a number, then to test the 
error try erroneous strings, 'only letters', 'letters and numbers', 'numbers 
then letters'. The first two produce the inbuilt error messages as expected the 
third produces parse errors on the loadline.
Cheers,
Peter Anderson

Quoting Miquel Cabanas <address@hidden>:

> On Wed, Feb 12, 2003 at 03:30:01PM +1100, address@hidden wrote:
> > 
> > Heres an interesting one:
> > I created a menu system to read in all the files in a directory
> > and then list them 10 at a time allowing users to change pages
> > or to select a file.
> 
> why don't you use the menu () m-function available in Octave, it
> seems to do the job you want.
> 
> as for the error,
> 
> > parse error:
> > 
> > >>> load -force materials/B45505.mtl
> > parse error:
> >
> > error: invalid character `' (ASCII 0) near line 49, column 45
> >
> > [...]
> >
> > >>> load -force materials/B45505.mtl
> > error: evaluating for command near line 23, column 3
> 
> I'm not convinced it's related to str2num. I rather suspect it's
> related to the use of "filelist(i,:)" in the eval () within the for
> loop.
> 
> > filelist=filelist(mtlfiles,:);
> ...
> > for i=Cpage_start:Cpage_finish
> > loadline=['load -force materials/',filelist(i,:),' matname'];
> > eval(loadline);
> 
> String matrices are padded with zeros so that all rows have
> the same length, if you want to get a string back and use it without
> problems you better strip it down and remove all extra space chars
> from its end using deblank (). I.e.
> 
> octave:145> filelist
> filelist =
> 
> getmat.m
> getmatv.m
> pand9613.m
> 
> octave:146> size (filelist)
> ans =
> 
>    3  38
> 
> octave:147> size (filelist(1,:))
> ans =
> 
>    1  38
>  
> octave:148> size (deblank (filelist(1,:)))
> ans =
> 
>   1  8
> 
> octave:149> deblank (filelist(1,:)) 
> ans = getmat.m
> 
> 
> Try replacing
> 
> > loadline=['load -force materials/',filelist(i,:),' matname'];
> 
> with
> 
> > loadline=['load -force materials/',deblank (filelist(i,:)),' matname'];
> 
> 
> 
> 
> Miquel
> 
> 
> 
> -- 
> Miquel E Cabanas ------------------------------------------------------
> SeRMN, Universitat Autonoma de Barcelona (address@hidden)
> ------------------------------------------o-oo--ooo---ooo--oo-o--------
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 
> 




-------------------------------------------------
This mail sent through IMP: www-mail.usyd.edu.au

Attachment: as3501.mtl
Description: Text document

Attachment: as43501c.mtl
Description: Text document

Attachment: as43501t.mtl
Description: Text document

Attachment: getmatv2.m
Description: Text document

Attachment: viewmat.m
Description: Text document


reply via email to

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