I want to make m.file which show limit. But when I run this m.file, my desktop doesn't stop working.
Please let me know what is wrong in the content below.
clear
function P=limitest(n)
P=(2*n.^3-4*n.+5)/(n.^3+3*n.^2-6)
endfunction
n=1
while limitest(n)-limitest(n-1)<10
n=n+1;
end
disp(limitest(n));
That is my m.file. I want to show limit about (2*n.^3-4*n.+5)/(n.^3+3*n.^2-6), (f(n)-f(n-1)<10, n : natural number)

댓글 수: 2

Juho
Juho 2020년 4월 16일
I would appreciate it if you teach me what's wrong!!
This is not MATLAB code:
endfunction

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

답변 (1개)

Rik
Rik 2020년 4월 16일

0 개 추천

It is fine to post questions related to GNU Octave, but you need to make sure that your issue is reproducible in Matlab.
It is unclear what your code is intended to do.
Why do you have clear without any code after it? (the function has its own workspace separate from the workspace that clear is working on) In Matlab this could be a nested function, but the outer function is missing and using clear midway a function is strange.
Trying to run your code separately also doesn't work:
P=(2*n.^3-4*n.+5)/(n.^3+3*n.^2-6)
% ^ ^
%.+ doesn't exist and this should be ./
Once those are fixed, it should already exit the loop at n=1:
n=1:100;
P=(2*n.^3-4*n+5)./(n.^3+3*n.^2-6);
P(2)-P(1) % 2.4286

카테고리

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

제품

질문:

2020년 4월 16일

답변:

Rik
2020년 4월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by