From: ricardo Huertas on
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
From: Wayne King on
"ricardo Huertas" <huertas_92(a)hotmail.com> wrote in message <hqmj3h$q8o$1(a)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