Please help me convert equation to matlab code.

116 次查看(过去 30 天)
adi putra
adi putra2018-4-1
评论: Walter Roberson ,2022-1-4,19:02
Deal all.
I need you help to convert this equation to matlab code
I spend a lot of time to write it but it doesn't work. Thank you.
  1 个评论
Walter Roberson
Walter Roberson 2018-4-1
Are you permitted to use the symbolic toolbox?
Is the question about providing some kind of symbolic proof, or is it about calculation of the formula using finite precision and a particular numeric input?


回答(7 个)

Birdman 2018-4-1
编辑:Birdman 2018-4-1
Basically, Symbolic Toolbox will help you:
syms y(x) n
  4 个评论


Roger Stafford
Roger Stafford 2018-4-1
N = 100; % <-- Choose some large number
s = x;
for n = 2*N-1:-2:1
s = x - s*x^2/((n+2)*(n+1));
(I think you meant to take the limit as N approaches infinity, not x.)

kalai selvi
kalai selvi 2020-9-15
pls answer this question to write the equation into code
  2 个评论
Walter Roberson
Walter Roberson 2020-9-15
π is written as pi in MATLAB.
exp of an expression is written as exp(expression) in MATLAB.
is written as sqrt(expression) in MATLAB.


Kunwar Pal Singh
Kunwar Pal Singh 2021-4-26
please answer to write this equation into MATLAB CODE
  1 个评论
Walter Roberson
Walter Roberson 2021-4-26
%these variables must be defined in a way appropriate for your situation
S_N = rand() * 10
theta = randn() * 2 * pi
l = randi([2 10])
b_1 = rand()
c_11 = rand()
t_year = randi([1950 2049])
d_11 = rand()
t_1 = rand()
t_x = t_1 + rand()
lambda_a = randi([500 579])
LOTF_a = rand()
P = rand()
K_l = rand()
k_0 = rand()
t_tau = randi(10)
overhaulcost_a = 1000 + rand()*100
%the work
syms t
part1 = int(S_N .* cos(theta) .* l .* b_1 .* t_year .* d_11, t, t_1, t_x);
part2 = int(lambda_a .* LOTF_a, t, t_1, t_x);
part3 = int(P*K_l .* t_year + P .* k_0 .* l .* l .* t_tau, t, t_1, t_x);
part4 = overhaulcost_a ;
result = part1 - part2 - part3 - part4;


Jakub Laznovsky
Jakub Laznovsky 2021-5-19
Hi guys, can you please help me with conversion this piece of code to the mathematical equation?
It i a simple 3D mask proceeding the image, and searching for adjoining number one and number two. Thank you in advance.
m1=[0 0 0; 0 1 0; 0 0 0];
m2=[0 1 0; 1 1 1; 0 1 0];
for i=2:size(image,1)-1
for j=2:size(image,2)-1
for k=2:size(image,3)-1
if sum(unique(help_var(mask==1)))==3
new_image(i,j,k)=3; %marks adjoining pixel with number 3
  4 个评论


Adhin Abhi
Adhin Abhi 2022-1-4,15:24
(λlog vmax−log vmin) /(vmax−vmin )

Community Treasure Hunt

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

Start Hunting!

Translated by