Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to use data from .m file into another?

0 views
Skip to first unread message

sayantani

unread,
Feb 10, 2012, 7:27:11 PM2/10/12
to
In the following code,i need 1 lakh samples in the array mydata.I dont know what i am getting out of mydata. Do i have to increase the range of t to get that. And how can i use the data in mydata into another .m file for further processing.

t = [ 1 : 1 : 500]; % Time Samples
f1=10000; % Input Signal Frequency
f2=20000;
f3=30000;
f4=f2+f3;
f5=f1+f3;
f6=f4+f2;
f7=f1+f6;
f8=45000;
f9=55000;
f10=35000;
mydata=[1:100000]; %output array
Fs = 100000; % Sampling Frequency
for i=1:100000
if(i<=10000)
mydata = sin(2*pi*f1/Fs*t);
elseif((i>10000)&&(i<=20000))
mydata=sin(2*pi*f2/Fs*t);
elseif((i>20000)&&(i<=30000))
mydata=sin(2*pi*f3/Fs*t);
elseif((i>30000)&&(i<=40000))
mydata=sin(2*pi*f4/Fs*t);
elseif((i>40000)&&(i<=50000))
mydata=sin(2*pi*f5/Fs*t);
elseif((i>50000)&&(i<=60000))
mydata=sin(2*pi*f6/Fs*t);
elseif((i>60000)&&(i<=70000))
mydata=sin(2*pi*f7/Fs*t);
elseif((i>70000)&&(i<=80000))
mydata=sin(2*pi*f8/Fs*t);
elseif((i>80000)&&(i<=90000))
mydata=sin(2*pi*f9/Fs*t);
elseif((i>90000)&&(i<=100000))
mydata=sin(2*pi*f10/Fs*t);
end
end
stem(mydata)

please help me. thank you

dpb

unread,
Feb 11, 2012, 2:49:44 PM2/11/12
to
On 2/10/2012 6:27 PM, sayantani wrote:
> In the following code,i need 1 lakh samples in the array mydata.

What is a lakh?

...

> ....how can i use the data in mydata into another .m file
> for further processing.

Pass the result back as the result of the function to the calling
function/workspace.

Read "Getting Started" on Programming, m-files, etc., etc., ...
>
> t = [ 1 : 1 : 500]; % Time Samples
> f1=10000; % Input Signal Frequency
> f2=20000;
> f3=30000;
> f4=f2+f3;
> f5=f1+f3;
> f6=f4+f2;
...

See response today on yesterday's thread on generating data "according
to sine function with changing period". Gives example w/ a set of fixed
frequencies; yours is no different other than the combination
frequencies in addition.

--
0 new messages