%i want to plot the function y=@(x) ((x.^2).*cos(pi.*x))/(((x.^3)+1).*(x+2)); where x increases from 0 to 1 in steps of 0.1

 채택된 답변

Peng Li
Peng Li 2020년 3월 25일

0 개 추천

If you define x first, I believe it's easy to write down the y?
x = 0:0.1:1;
y = (x.^2).*cos(pi.*x)) ./ (((x.^3) + 1).*(x + 2);
plot(x, y);
Note: I believe that you should use ./ instead of / directly as it doesn't meet the requirement for matrix/vector division.

댓글 수: 3

Thank you!
Mary Jean Savitsky
Mary Jean Savitsky 2020년 3월 25일
편집: Mary Jean Savitsky 2020년 3월 25일
what if i wanted the 100 linearly-spaced values of x between 0 and 1?
Peng Li
Peng Li 2020년 3월 25일
using x = 0:0.1:1, you get 11 values between 0 and 1, with step 0.1. If you want 100 such values, you can use x = linspace(0, 1, 100);

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2020년 3월 25일

댓글:

2020년 3월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by