MATLAB Answers

Error with plotting my function

조회 수: 20(최근 30일)
Ethan Bales
Ethan Bales 2021년 9월 18일 19:25
댓글: Star Strider 2021년 9월 18일 20:34
Having issues getting my nonlinear function to plot.
f = @(x) 2.^x-5*x+2; %Given Function
xaxis = [0:0.5:2]; %x-axis
plot(xaxis,f) %plotting function //DOESN'T WORK
  댓글 수: 2
Ethan Bales
Ethan Bales 2021년 9월 18일 20:15
yeah sorry about that. This is my first time using a forum like this and I'm still relatively new to coding. Thanks for insight!

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

채택된 답변

Star Strider
Star Strider 2021년 9월 18일 19:37
It works if you give ‘f’ a vector to work with
f = @(x) 2.^x-5*x+2; %Given Function
xaxis = [0:0.5:2]; %x-axis
plot(xaxis,f(xaxis)) %plotting function //DOESN'T WORK —> YEs, IT DOES!
Experiment to get different results.
.
  댓글 수: 2
Star Strider
Star Strider 2021년 9월 18일 20:34
My pleasure!
.

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

추가 답변(0개)

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by