Please help!!!!First input must be a function handle
조회 수: 2 (최근 30일)
이전 댓글 표시
this is my code:
syms x;
a = -5;
b = 5;
f = 1/(1+x^2);
n=57;
h = (b-a)/(2*n);
k = linspace(a,b,2*(n+1));
s = arrayfun(f,k);
I want to aplly f to all the elements of k but it gives a error "First input must be a function handle"
Thx for your time
댓글 수: 0
채택된 답변
Stephan
2018년 5월 13일
편집: Stephan
2018년 5월 13일
Hi
try this:
syms x;
a = -5;
b = 5;
f = @(x)1/(1+x^2);
n=57;
h = (b-a)/(2*n);
k = linspace(a,b,2*(n+1));
s = arrayfun(f,k);
Best regards
Stephan
댓글 수: 2
Stephan
2018년 5월 13일
Hi Alex,
nice. Please accept helpful answers in order to help people with similar problems finding helpful answers.
Best regards
Stephan
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!