|
|
Problems with functions
Hi im having a problem using Matlab, I will be really grateful if someone could help or give me a hint on the error in my code so here it goes:
I have to create a function to plot a sine wave with different parameter as: amplitude(A), phase(theta), fequency(f), sample frequency(fs) and end time(T_end), so I was given this first line:
function [x, t] = single_sine(f, A, theta, T_end, fs);
and then I added the following:
ts = 1./fs;
t = 0:ts:T_end-fs;
x = A.*sin(2.*pi.*f.*t);
plot(t,x)
to me it seems allright but then it gave me this result for both the values of t and x:
'Empty matrix: 1-by-0'
if anyone could give me a hand...cause im totally lost
|
|
0
|
|
|
|
Reply
|
ricardo
|
4/21/2010 10:13:05 AM |
|
"ricardo Huertas" <huertas_92@hotmail.com> wrote in message <hqmj3h$q8o$1@fred.mathworks.com>...
> Hi im having a problem using Matlab, I will be really grateful if someone could help or give me a hint on the error in my code so here it goes:
> I have to create a function to plot a sine wave with different parameter as: amplitude(A), phase(theta), fequency(f), sample frequency(fs) and end time(T_end), so I was given this first line:
> function [x, t] = single_sine(f, A, theta, T_end, fs);
>
> and then I added the following:
> ts = 1./fs;
> t = 0:ts:T_end-fs;
> x = A.*sin(2.*pi.*f.*t);
> plot(t,x)
>
> to me it seems allright but then it gave me this result for both the values of t and x:
> 'Empty matrix: 1-by-0'
>
> if anyone could give me a hand...cause im totally lost
Hi Ricardo, I don't know what values you are inputting in your function for f,A, etc., but look at the line:
t = 0:ts:T_end-fs;
Think about what you are asking Matlab to do there. I think that's your problem.
Wayne
|
|
0
|
|
|
|
Reply
|
Wayne
|
4/21/2010 10:54:08 AM
|
|
|
1 Replies
167 Views
(page loaded in 3.624 seconds)
|
|
|
|
|
|
|
|
|