From: Harry on
Hi,

I'm having soming trouble to define correctly how to load a file.

Stored in "a" i have a string
Stored in "b" i have a number
I want to load a file with the name "a"_"b".txt

For example:
in "a" there is the word "car"
in "b" there is a value 500
i want to load the file "car_500.txt"

How should I do this? I hope you can help me out!
Thanks in advance! Greetings from Brussels!
From: dpb on
Harry wrote:
> Hi,
>
> I'm having soming trouble to define correctly how to load a file.
>
> Stored in "a" i have a string
> Stored in "b" i have a number
> I want to load a file with the name "a"_"b".txt
>
> For example:
> in "a" there is the word "car"
> in "b" there is a value 500
> i want to load the file "car_500.txt"
>
> How should I do this? I hope you can help me out!

A couple of the almost unlimited ways...

>> a='car';
>> b=500;
>> fname=[a '_' num2str(b) '.txt']
fname =
car_500.txt
>> fname=sprintf('%s_%0d.txt', a,b)
fname =
car_500.txt
>>


--
From: Harry on
Thank you very much!!
 | 
Pages: 1
Prev: Pause analog input
Next: Vectorize This