differentiating function & getting different answer
조회 수: 8 (최근 30일)
이전 댓글 표시
hey! I was trying to differentiate this function g(x)=3x-1 and despite the fact that I followed the code provided on the matlab website to a "t", the answer I got within matlab was incorrect. I included a link to the example as well as screenshots of the code they provided and how it appears in my command window.
here's how the code appears on the site:

I typed the same code into my command window but got a different answer...

I'm really confused at this point because now whenever I try to differentiate ANY function I get the same answer!
답변 (2개)
James Tursa
2019년 2월 7일
편집: James Tursa
2019년 2월 7일
Perhaps you are shadowing the MATLAB function diff with a function of your own. Make sure diff is pointing to the MATLAB function.
댓글 수: 0
Noah Barrow
2019년 2월 7일
댓글 수: 4
Walter Roberson
2019년 2월 8일
Execute the command
clearvars
and then run your code again. If the same thing happens, then track down where in your code you assign something to a variable named diff and use a different variable name instead.
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!