Re: loading files using eval ' problem



Pep <peppuigvert@xxxxxxxxx> wrote in message
<9d68855a-99ab-4c64-bd0c-2d9740381f7f@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...
Hi there!

I have the following problem:

I can upload some files which have the following format:

initp1 = load('initial_parameters1.txt');
initp2 = load('initial_parameters2.txt');
initp3 = load('initial_parameters3.txt');
initp4 = load('initial_parameters4.txt');

I am trying to use eval

for i = 1:4

eval(['initp',
num2str(i),'=load(initial_parameters',num2str(i),'.txt);'])

end

But since I need to insert the ' character after the load
and after
the txt' I can not use it.

I am in the directory where the files are stored
/global/proddatadg/

sdpe/production/MBS/devel/fmsu_pdfs/pdf_results/init_parameters
(In fact I can do initp4 =
load('initial_parameters4.txt'); with no
problems)

and I have tried to use

addpath('/global/proddatadg/sdpe/production/MBS/devel/fmsu_pdfs/
pdf_results/init_parameters");

Does anyone know how to solve the ' problem?

Thank you very much in advance.

Kind regards,

Pep
Why use eval ? It is a bad way.
Use cell array instead :
for i=1:4
initp{i} = load(sprintf('initial_parameters%d.txt',i));
end

BTW to put a ' in a string you just have to double it e.g. :
str='string with '' inside and at the end'''

Caroline
.



Relevant Pages

  • Re: Http post
    ... Now if you were for example to build a string out of these 3 things ... Two separate HTTP Post request are required to complete the upload ... The example you sent me works fine and the authentication id can be ... perhaps just simple text string with an attachment (in binary format) ...
    (microsoft.public.fox.programmer.exchange)
  • Re: For the last time
    ... He changes the format by converting it to a mp3. ... He uploads the mp3 to a peer-to-peer site. ... copyright laws no longer apply to the artistic work. ... for upload for other people to get free, or shared the files with other ...
    (rec.music.progressive)
  • Re: Design question
    ... Big fish eat little fish ... This is probably not the case and all vendors will have their own format. ... I would go ahead and account for specifying an upload format per vendor type and creating a provider model type parser. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Design question
    ... Big fish eat little fish ... You create a common format ... Vendor states to salesman he can "go to hell" if he can't use his Excel ... upload format per vendor type and creating a provider model type parser. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: They dont know theyve been to Earth
    ... remove MP3 support from iTunes than to leave it in. ... "Microsoft Personality Upload 1.0 for Windows 2050". ... format is actually just a standard .zip file containing relatively ... So I'd bet that either Personality Upload will use an open format, ...
    (rec.arts.sf.written)