function slope ??? Undefined function or method
조회 수: 13 (최근 30일)
이전 댓글 표시
??? Undefined function or method 'slope' for input arguments of type 'double'.
the code is
decay(j-2,j9)=mean (slope(1:j5-1,j1));
how can i plot slope but my matlab don't have slope function
help me plz
댓글 수: 0
답변 (4개)
Wayne King
2013년 4월 30일
slope() is not a Mathworks function, but you can use polyfit() to fit a first-order polynomial to some data and get the slope by extracting the coefficient corresponding to the first power.
x = 0:20;
y = 2*x+0.01*randn(size(x));
coefs = polyfit(x,y,1);
The estimated slope is coefs(1)
댓글 수: 0
Jan
2013년 4월 30일
So what kind of help do you expect? My Matlab does not have a slope function also. It is also not clear, what this function should calculate. When it is the slope, what do you expect as output for "1:j5.1"? Obviously this is a constant and trivial to calculate.
Perhaps gradient helps already.
댓글 수: 0
Nawawit
2013년 4월 30일
댓글 수: 1
Walter Roberson
2021년 2월 13일
the problem is not a missing function slope. The problem is that
if j3>1;
for j4=1:j3-1
slope(j5,j1)=(cropdata(j3,2,j1)-cropdata(j3-j4,2,j1))/(cropdata(j3,1,j1)-cropdata(j3-j4,1,j1));
j5=j5+1;
end
is never true so that you never assign to the variable named slope
Yash Chordia
2021년 2월 12일
편집: Yash Chordia
2021년 2월 12일
You can brute force it by the actual formula of slope ---> f(x +Δx) - f(x) / Δx
%slope
for count = 1:length(y)-1
v(count) = (y(count + 1) - y(count))/(t(count + 1) - t(count));
end
%v has one less element than y so, correcting it
v(length(y)) = v(length(y)-1)
you can adjust the code accordig to your requiremnt. Here we are calculating slope of y
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!