필터 지우기
필터 지우기

how to change U(0,t) = 1 to Ux(0,t) = 1

조회 수: 1 (최근 30일)
Omar Benavente
Omar Benavente 2022년 2월 10일
답변: Shushant 2023년 9월 26일
a = @(t) 1;
b = @(t) 1;
xArray = dx*(0:J);
tArray = dt*(0:N);
for n = 1 : N
u(1, n+1)=a(tArray(n+1)); % Boundary Conditions at x=0
u(J+1, n+1)=b(tArray(n+1)); % Boundary Conditions at x=1
for j = 2 : J
u(j, n+1) = u(j,n) + mu*(u(j+1,n) - 2*u(j,n) + u(j-1,n));
end
end
I have the two boundaries of u(0,t) = 1and u(1,t), What if I change the boundary condition u(0,t) =1 to ux(0,t) = 1(differentiate with respect to x). How do I change my boundary condition to ux(0,t) = 1 according to my code?
Sincerely yours,
Omar

답변 (1개)

Shushant
Shushant 2023년 9월 26일
Hi Omar Benavente,
I understand that you have an equation "u(0,t) = 1" and you want to differentiate this equation with respect to "x" to obtain "ux(0,t)".
To define an equation in terms of "x", you need to first make "x" a symbolic object. Refer to the following documentation for more information on "syms" and how to make a variable into a symbolic object-
Then you have to define "u(0,t)" in terms of the symbolic object "x". Afterwards, you can use the "diff" function to differentiate "u(0,t)" to obtain "ux(0,t)". Refer to the following documentation for more information on how to use "diff" function with symbolic objects-
I hope this helped in solving the issue you were facing.
Thank you,
Shushant

카테고리

Help CenterFile Exchange에서 Assembly에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by