Vector as input for plotting function

Hello,
i would like to plot with red stars the function: sinc(x)= [sin(πx)]/[πx]
but x would be a vector given by the user
I really dont know how to ask the user to give me the vector and how can i use it as input for my function.

Respuestas (1)

madhan ravi
madhan ravi el 2 de Jun. de 2020
Editada: madhan ravi el 2 de Jun. de 2020
x = input('Values of x:') % feed in for example [1,2,3]
y = @sinc;
plot(x,y(x))

4 comentarios

Eleftherios Venizelos
Eleftherios Venizelos el 2 de Jun. de 2020
and what about the [sin(πx)]/[πx]?
madhan ravi
madhan ravi el 2 de Jun. de 2020
Editada: madhan ravi el 2 de Jun. de 2020
Huh? Is it hard for you to type that? I should type that for you comeon! Make some effort!
doc sinc
Eleftherios Venizelos
Eleftherios Venizelos el 2 de Jun. de 2020
Editada: Eleftherios Venizelos el 2 de Jun. de 2020
No, i mean that it goes:
x = input('Values of x:') % feed in for example [1,2,3]
y=@sinc;
sinc= [sin(πx)]/[πx];
plot(x,y(x))
right?
clear sinc
y = @(x) sin(pi*x) ./ (pi*x);

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 2 de Jun. de 2020

Comentada:

el 2 de Jun. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by