How do you plot the following function?

y_num = @(x) cos(x).*(sin(x)).^3;
I_num = @(xmin, xmax) integral(y_num, xmin, xmax);
xmin = 0;
xmax = 2*pi;
%%plot(x, I_num) displays error "Error using plot. Data must be numeric, datetime, duration or an array convertible to double."

답변 (1개)

Walter Roberson
Walter Roberson 2019년 10월 27일

0 개 추천

xvals = linspace(xmin, xmax);
yvals = arrayfun(@(XMAX) I_num(xmin, XMAX), xvals);
plot(xvals, yvals);
This will not be efficient, as it ends up re-integrating areas it has already done. It would be more efficient to integrate segment by segment and cumsum() the result.

카테고리

도움말 센터File Exchange에서 Octave에 대해 자세히 알아보기

제품

릴리스

R2019b

태그

질문:

2019년 10월 27일

답변:

2019년 10월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by