Re: loading files using eval ' problem
- From: "French Caro " <caro95470@xxxxxxxxxxxxxx>
- Date: Tue, 17 Jun 2008 09:23:01 +0000 (UTC)
Pep <peppuigvert@xxxxxxxxx> wrote in message
<9d68855a-99ab-4c64-bd0c-2d9740381f7f@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...
Hi there!and after
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
the txt' I can not use it./global/proddatadg/
I am in the directory where the files are stored
sdpe/production/MBS/devel/fmsu_pdfs/pdf_results/init_parameters
(In fact I can do initp4 =load('initial_parameters4.txt'); with no
problems)addpath('/global/proddatadg/sdpe/production/MBS/devel/fmsu_pdfs/
and I have tried to use
pdf_results/init_parameters");Why use eval ? It is a bad way.
Does anyone know how to solve the ' problem?
Thank you very much in advance.
Kind regards,
Pep
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
.
- References:
- loading files using eval ' problem
- From: Pep
- loading files using eval ' problem
- Prev by Date: Re: loading files using eval ' problem
- Next by Date: Re: loading files using eval ' problem
- Previous by thread: Re: loading files using eval ' problem
- Next by thread: Re: loading files using eval ' problem
- Index(es):
Relevant Pages
|