From: kuns on
I am generating a n dimensional data set with matlab , now I want to save this to a text file , with name data10 ,data 20 ... data100.txt .. depending upon number of dimensions , how can I use the same function to generate different files ??

here is the function I used to generate the data

function [ ] = datagen(k)

class1 = normrnd(5,2,100,k);
class2 = normrnd(15,2,100,k);
class3 = normrnd(25,2,100,k);

total = [class1;class2;class3];

save("'LinRegDatak.txt'",'total','-ASCII');

end
From: ImageAnalyst on
You can use sprintf() to build up your filename.
From: Steven Lord on

"kuns" <kunal10mulay(a)gmail.com> wrote in message
news:14281658.470730.1269953784488.JavaMail.root(a)gallium.mathforum.org...
>I am generating a n dimensional data set with matlab , now I want to save
>this to a text file , with name data10 ,data 20 ... data100.txt ..
>depending upon number of dimensions , how can I use the same function to
>generate different files ??
>
> here is the function I used to generate the data
>
> function [ ] = datagen(k)
>
> class1 = normrnd(5,2,100,k);
> class2 = normrnd(15,2,100,k);
> class3 = normrnd(25,2,100,k);
>
> total = [class1;class2;class3];
>
> save("'LinRegDatak.txt'",'total','-ASCII');

See question 4.12 in the newsgroup FAQ.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ