I need help writing equation in matlab

1 回表示 (過去 30 日間)
matlab
matlab 2023 年 1 月 24 日
コメント済み: Image Analyst 2023 年 1 月 25 日
how do i write this equation in a matlab script

回答 (2 件)

Image Analyst
Image Analyst 2023 年 1 月 24 日
This looks like a homework problem. If you have any questions ask your instructor or read the link below to get started:
Obviously we can't give you the full solution because you're not allowed to turn in our code as your own.
Some hints to get you started:
n = 5;
v = 1 : n
v = 1×5
1 2 3 4 5
denom = 1 ./ v
denom = 1×5
1.0000 0.5000 0.3333 0.2500 0.2000
x = 3;
num = x .^ v
num = 1×5
3 9 27 81 243
To learn other fundamental concepts, invest 2 hours of your time here:
  2 件のコメント
matlab
matlab 2023 年 1 月 24 日
its not for an assignment, Im doing practice on my own and I cant figure out how to write the eqation in matlab and I learn best from examples
Image Analyst
Image Analyst 2023 年 1 月 25 日
Here is it in more steps than needed just to show you each step involved.
% Call the function with x=10 and n=5
output = e(10, 5)
%-------------------------------------------------------------------
% function definition:
function output = e(x, numberOfTerms)
v = 0 : numberOfTerms
denom = factorial(v)
denom = 1 ./ denom
numerator = x .^ v
output = numerator ./ denom
output = sum(output)
end

サインインしてコメントする。


Walter Roberson
Walter Roberson 2023 年 1 月 25 日
format long g
syms x n m
result = symsum(x^n/factorial(n), n, 0, m)
result = 
limit(result, m, inf)
ans = 
result20 = subs(result, m, 20)
result20 = 
exp20 = subs(result20, x, sym(pi))
exp20 = 
exp20_numeric = double(exp20)
exp20_numeric =
23.1406926321509
exact = exp(sym(pi))
exact = 
exact_numeric = double(exact)
exact_numeric =
23.1406926327793
exact_numeric - exp20_numeric
ans =
6.28368468369445e-10

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by