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.
回答(1 个)
madhan ravi
2020-6-2
编辑:madhan ravi
2020-6-2
x = input('Values of x:') % feed in for example [1,2,3]
y = @sinc;
plot(x,y(x))
4 个评论
Eleftherios Venizelos
2020-6-2
madhan ravi
2020-6-2
编辑:madhan ravi
2020-6-2
Huh? Is it hard for you to type that? I should type that for you comeon! Make some effort!
doc sinc
Eleftherios Venizelos
2020-6-2
编辑:Eleftherios Venizelos
2020-6-2
madhan ravi
2020-6-2
clear sinc
y = @(x) sin(pi*x) ./ (pi*x);
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!