필터 지우기
필터 지우기

I need help due to unrecognized function or variable ' x ' error, please.

조회 수: 2 (최근 30일)
B
B 2023년 11월 25일
댓글: Walter Roberson 2023년 11월 25일

답변 (2개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 11월 25일
Here is how to call a function
x = linspace(-10,10);
f=randi(15, size(x));
ANSWER = dd(x,f)
ANSWER = 1×100
1.0e+03 * 0.0140 -0.0099 -0.0858 0.3436 -0.5003 -0.0743 1.7367 -3.9587 5.6320 -5.9887 5.1183 -3.6821 2.3249 -1.3547 0.7778 -0.4700 0.3062 -0.2078 0.1389 -0.0877 0.0513 -0.0275 0.0135 -0.0061 0.0025 -0.0010 0.0003 -0.0001 0.0000 -0.0000
function a = dd(x, f)
n = length(x);
a =f;
for jj=2:n
for ii=n:-1:jj
a(ii) = (a(ii)-a(ii-1))/(x(ii)-x(ii-jj+1));
end
end
end
  댓글 수: 2
B
B 2023년 11월 25일
The unrecognized function or variable ' x ' error still persists.
Walter Roberson
Walter Roberson 2023년 11월 25일
The output shown above, the "ANSWER = " and so on, is output from executing the code here in MATLAB Answers. The code runs successfully, with no error about x

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


Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 11월 25일
Put this code in one M-file or MLX editor window, and hit ctrl+enter
x = linspace(-10,10);
f=randi(15, size(x));
ANSWER = dd(x,f)
function a = dd(x, f)
n = length(x);
a =f;
for jj=2:n
for ii=n:-1:jj
a(ii) = (a(ii)-a(ii-1))/(x(ii)-x(ii-jj+1));
end
end
end

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by