Please help me convert equation to matlab code.

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

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?

답변 (8개)

Birdman
Birdman 2018년 4월 1일
편집: Birdman 2018년 4월 1일
Basically, Symbolic Toolbox will help you:
syms y(x) n
f(x)=symsum((-1).^n*(x.^(2*n+1))/factorial(2*n+1),n,0,Inf)

댓글 수: 4

so, how i can get sin(x)? ex sin(90)?
Birdman
Birdman 2018년 4월 1일
편집: Birdman 2018년 4월 1일
Now that you have f(x)=sin(x), simply write
f(90)
but remember that sin function takes input arguments in radians, you need to write
f(pi/2)
to get a numerical result.
@Birdman: I think you meant f(pi/2)
Yes, I just now edited it Roger.
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));
end
(I think you meant to take the limit as N approaches infinity, not x.)
kalai selvi
kalai selvi 2020년 9월 15일

0 개 추천

pls answer this question ...how to write the equation into code

댓글 수: 2

Please don't post a completely distinct question as an answer.
π is written as pi in MATLAB.
exp of an expression is written as exp(expression) in MATLAB.
is written as sqrt(expression) in MATLAB.
kalai selvi
kalai selvi 2020년 9월 16일

0 개 추천

How to write a code on IOTA filter in fbmc system

댓글 수: 2

Walter Roberson
Walter Roberson 2020년 9월 16일
편집: Walter Roberson 2020년 9월 17일
Warning: pudn has questionable security. Take precautions when you access it.
thank you
Kunwar Pal Singh
Kunwar Pal Singh 2021년 4월 26일

0 개 추천

please answer this....how to write this equation into MATLAB CODE

댓글 수: 1

%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.
Code:
m1=[0 0 0; 0 1 0; 0 0 0];
m2=[0 1 0; 1 1 1; 0 1 0];
mask=zeros(3,3,3);
mask(:,:,1)=m1;mask(:,:,2)=m2;mask(:,:,3)=m1;
for i=2:size(image,1)-1
for j=2:size(image,2)-1
for k=2:size(image,3)-1
help_var=image(i-1:i+1,j-1:j+1,k-1:k+1);
if sum(unique(help_var(mask==1)))==3
new_image(i,j,k)=3; %marks adjoining pixel with number 3
end
end
end
end

댓글 수: 4

What are the permitted values inside image ? The code logic posted would work if the array is all 1's and 2's, but it would also work if 0's could also be present. The logic could potentially also locate regions that were exclusively 3's.
The logic looks at the "adjacent faces" of each pixel (no diagonals), and it believes it is detecting that if the center pixel is 1 then there is a 2 among the 6 faces, and it believes it is detecting that if the center pixel is 2 then there is a 1 among the 6 faces. However, that is not what is actually happening if 0's or 3's are possible in the matrix.
The code can written without loops, and more accurately.
se1 = [0 0 0; 0 1 0; 0 0 0]; se2 = [0 1 0; 1 0 1; 0 1 0]; %do not set center
mask = cat(3, se1, se2, se1);
m1 = image == 1;
m2 = image == 2;
r1 = m1 & imdilate(m2, mask);
r2 = m2 & imdilate(m1, mask);
new_image = zeros(size(image));
new_image(r1 | r2) = 3;
Jakub
Jakub 2021년 5월 21일
Dear Walter,
thanks for the detailed reply. The permitted values in the image variable are 0's,1's and 2's. Location of the regions that were exclusively 3's is not desired for my purposes.
Thanks for your code, it works really well and much faster.
However, I'm still wondering, how to express this logic by a mathematical equation, do you have any idea?
Thanks, best regards
Jakub
Jakub 2021년 5월 22일
Thanks a lot!
Adhin Abhi
Adhin Abhi 2022년 1월 4일

0 개 추천

(λlog vmax−log vmin) /(vmax−vmin )

댓글 수: 1

(lambda .* log(vmax) - log(vmin)) ./ (vmax - vmin)
Lukasz Sarnacki
Lukasz Sarnacki 2022년 8월 17일

0 개 추천

Please help

댓글 수: 5

What is ? The looks like the Modified Bessel Function of the First Kind, MATLAB besseli(n, Z) -- but that function only accepts one parameter beyond the ν .
Lukasz Sarnacki
Lukasz Sarnacki 2022년 8월 17일
편집: Lukasz Sarnacki 2022년 8월 17일
In distorted fringe distribution, denoted as In(x; y) captured by the camera.
n represents the phase-shift index n = 0; 1; 2; :::;N - 1.
This equation is Standard N-step phase shifting.
Walter Roberson
Walter Roberson 2022년 8월 17일
편집: Walter Roberson 2022년 8월 17일
Are A and B and ϕ functions, or are they arrays?
Thay all are arrays
A(x; y) is the average intensity of the fringe image
B(x; y) is the so-called intensity modulation.
ϕ is the corresponding wrapped phase
syms n N integer
syms A(x,y) B(x,y) phi(x,y)
Pi = sym(pi)
Pi = 
π
I(n,x,y) = A(x, y) + B(x,y) * cos(phi(x,y) - 2*Pi*n/N)
I(n, x, y) = 
numerator = simplify(symsum(I(n, x, y) .* sin(2*Pi*n/N), n, 0, N-1))
numerator = 
denominator = simplify(symsum(I(n, x, y) .* cos(2*Pi*n/N), n, 0, N-1))
denominator = 
eqn = phi(x,y) == atan(numerator ./ denominator)
eqn = 
simplify(eqn)
ans = 

This question is locked.

카테고리

질문:

2018년 4월 1일

Locked:

Rik
2024년 7월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by