How to express extremes??
Afficher commentaires plus anciens
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)
Réponses (1)
Rik
le 16 Avr 2020
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
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!