Hello gradient (140,150), the answer is 0, but it exIhere is my error please? Also, is diff for calculating the derivative? GS.

 채택된 답변

Stephen23
Stephen23 2017년 9월 6일

0 개 추천

Why would you expect
>> gradient(140,150)
ans = 0
to be non-zero? You are asking for the gradient at one point... to be honest I am surprised that it does not return NaN. Did you read the gradient documentation to know what the two arguments are for?
Perhaps you really wanted to do this:
>> gradient([140,150])
ans =
10 10
"Also, is diff for calculating the derivative?"
Did you read the diff documentation? It answers your question, right on the very first line.

댓글 수: 6

Gavin Seddon
Gavin Seddon 2017년 9월 7일
Hello and thank you, this compares the difference. It does not take into account the Y Change? Is it best to use dIff?
GS.
Stephen23
Stephen23 2017년 9월 7일
"Is it best to use dIff?"
Different tools do different things. Is a hammer better than a spade?
Gavin Seddon
Gavin Seddon 2017년 9월 13일
Hello yes dIff(function) worked.
John D'Errico
John D'Errico 2017년 9월 13일
편집: John D'Errico 2017년 9월 13일
Hmm. "Is a hammer better than a spade?" After a great deal of careful thought, I can only ascertain that some fellows named Art G. and Paul S. have told us that I'd rather be a hammer than a nail. Perhaps more research is necessary on my part. Time to revisit some more music that many of those reading this comment will not even recognize. ;-)
Stephen23
Stephen23 2017년 9월 13일
@John D'Errico: while we should clearly acquiesce to Messrs Simon and Garfunkel's authority on the subject of hammers vs. nails, how do spades fit into this? It leaves us with some small conundrums to resolve: is the relationship between spades, hammers, and nails associative and/or commutative? Can this be generalized to all tools? Who can write the simplest vectorized code for this?
John D'Errico
John D'Errico 2017년 9월 13일
편집: John D'Errico 2017년 9월 13일
I think I need next to visit Scarborough Fair. They have a large library there, wherein I can do the necessary research. For example, are spades lesser or greater than nails? I think what matters is if some sort of transitivity relation exists in this matter.

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

추가 답변 (0개)

카테고리

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

질문:

2017년 9월 6일

편집:

2017년 9월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by