creating a loop to generate a plot

์กฐํšŒ ์ˆ˜: 2 (์ตœ๊ทผ 30์ผ)
Kalpha.mc
Kalpha.mc 2020๋…„ 10์›” 30์ผ
ํŽธ์ง‘: VBBV 2020๋…„ 10์›” 31์ผ
I don't quite undertsnad this question could i please get some help?
Create a for loop to generate the first 20 terms of the estimation of e given by
(1+(1/n))^n โ‰ˆ ๐‘’. Store all the individual estimates in an array called terms. Then plot the terms array to see the value get closer and closer to 2.7183, using a logarithmic y axis, as shown below.
here is what i have so far
clc,clear
x = 0;
for n = 1:20
y = (1 + (1/n).^n);
x = x + y;
end
x1 = 2.7183;
for index = 1:20
y1 = (1 + (1/index).^index);
x1 = y1 - x1;
end
plot(x1,x)
axis([0,20 ,2, 2.8])

์ฑ„ํƒ๋œ ๋‹ต๋ณ€

VBBV
VBBV 2020๋…„ 10์›” 31์ผ
ํŽธ์ง‘: VBBV 2020๋…„ 10์›” 31์ผ
%if true
% code
%end
n = 1:100;
YY = (1+1./n).^n;
plot(n,YY); figure(2);semilogy(YY,n);
  ๋Œ“๊ธ€ ์ˆ˜: 1
VBBV
VBBV 2020๋…„ 10์›” 31์ผ
ํŽธ์ง‘: VBBV 2020๋…„ 10์›” 31์ผ
If you want to use loop like your code. See the parenthesis in your code.
%if true
% code
%end
clc,clear
k = 1:200;
for n = 1:200
y(n) = (1 + (1/n))^n; % see the parenthesis in your code.
end;
plot(k,y); axis([0 200 2 3]);
figure(2)
semilogy(k,y)

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (0๊ฐœ)

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ Matrices and Arrays์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

Community Treasure Hunt

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

Start Hunting!

Translated by