For Programmers: Free Programming Magazines  


Home > Archive > Matlab > January 2008 > eval









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author eval
Andrea Murray

2008-01-31, 10:18 am

I have run a program using the subroutine below for months
and it has worked.


function [AutoX, AutoY]= gettlmauto(DataPath1, Name)

FileName = Name(1:end-2)
Current = a;
cd(DataPath1);
eval(FileName);
cd(Current);

The function opens a file in the DataPath1 directory called
filename.m. The file has the following format:

AutoX = [5017,4885,4700,4189];

AutoY = [70,214,399,263];


Suddenly it no longer works - I k[now there must be
something in the code elsewhere that I have changed that
has caused this, but I also know that eval is temperamental
and I'd prefer to have a more robust way of dealing with
this problem rather than trying to work out what I've
changed. Any suggestions?
Jos

2008-01-31, 10:18 am

"Andrea Murray" <andrea.murray1@zen.co.uk> wrote in message
<fnsc33$4k5$1@fred.mathworks.com>...
> I have run a program using the subroutine below for months
> and it has worked.
>
>
> function [AutoX, AutoY]= gettlmauto(DataPath1, Name)
>
> FileName = Name(1:end-2)
> Current = a;
> cd(DataPath1);
> eval(FileName);
> cd(Current);
>
> The function opens a file in the DataPath1 directory called
> filename.m. The file has the following format:
>
> AutoX = [5017,4885,4700,4189];
>
> AutoY = [70,214,399,263];
>
>
> Suddenly it no longer works - I k[now there must be
> something in the code elsewhere that I have changed that
> has caused this, but I also know that eval is temperamental
> and I'd prefer to have a more robust way of dealing with
> this problem rather than trying to work out what I've
> changed. Any suggestions?



Ouch ... this code hurts.

But let's try to help.
1. there is an unexplained a in the file "current=a"

2. Do you really need to do it this way? Why not store autox
and autoy in mat-file or text-file and read them in using
the functional form of load or textread?

hth
Jos

Yumnam Kirani Singh

2008-01-31, 10:18 am

What is there in the input variable Name?
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com