Vector as input for plotting function

조회 수: 11 (최근 30일)
Eleftherios Venizelos
Eleftherios Venizelos 2020년 6월 2일
댓글: madhan ravi 2020년 6월 2일
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
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
Eleftherios Venizelos 2020년 6월 2일
편집: Eleftherios Venizelos 2020년 6월 2일
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?
madhan ravi
madhan ravi 2020년 6월 2일
clear sinc
y = @(x) sin(pi*x) ./ (pi*x);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by