function x=signal(f,fs,N)
% sinusoid
f=30; %frequency,
N=10; %number of samples
fs=100; %sampling frequency
A=2; %amplitute
Total sampling time = 1 second
n = 0:N-1; % numbering the samples
x = A*sin(2*pi*f*n/fs);
plot(x)
MFx = abs(fft(x));
frek=(0:N/2-1)*fs/N;
plot(frek,MFx(1:N/2))% plot the positive frequencies
please help me.
thank you

4 comentarios

John D'Errico
John D'Errico el 30 de Mzo. de 2016
What did you try? What did MATLAB do when you tried to use it? Oh, and tell me that you did NOT try to use the run command on it. You don't "run" functions.
Image Analyst
Image Analyst el 30 de Mzo. de 2016
Did you type F5, or click the green run triangle on the tool ribbon? If you did that, you'll need a test script to make arguments and call signal() because you can't run signal() without suppyling arguments.
Or did you supply arguments in the command window?
Kuheli Mondal
Kuheli Mondal el 31 de Mzo. de 2016
now its runing..Thank you all..........
Muhammad Usman Saleem
Muhammad Usman Saleem el 31 de Mzo. de 2016
fine. Then please accept my answer. if you would like

Iniciar sesión para comentar.

 Respuesta aceptada

Muhammad Usman Saleem
Muhammad Usman Saleem el 30 de Mzo. de 2016

0 votos

mark this line as comment
%Total sampling time = 1 second

3 comentarios

Kuheli Mondal
Kuheli Mondal el 31 de Mzo. de 2016
Thank you very mach.I already do that one.but that also not working.
Walter Roberson
Walter Roberson el 31 de Mzo. de 2016
You need to tell us how you are running the program, and you need to show the complete error message.
Image Analyst
Image Analyst el 31 de Mzo. de 2016
Kuehli, now you've been asked three times to show what you did. What arguments you supplied and how you ran it. Did you overlook the two comments up at the top? Why did you not answer them? Why don't you want to make it easy to help you instead of hard or impossible?

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 31 de Mzo. de 2016

0 votos

Kuheli, the attached m-file (below the plot) runs perfectly fine. It runs via the green run triangle, and it runs via typing F5. AND it runs with no errors at all and makes the plot below. It's all in one m-file, text3.m and is attached. If you can't run it, let me know, otherwise you can Accept this answer.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by