Incorrect use of '=' operator. Assign a value to a variable using '=' and compare values for equality using '=='.

조회 수: 2 (최근 30일)
D=0.1;
U=1;
K= 1*10^-6;
ci=3;
co=2;
L=1;
y(1) =C;
y(2) = dc/dx;
y(2)'=dc^2/dx^2;
function dcdx = bvpfcn(c,x) % euation to solve
dcdx= y(2)(U*y(2)+K*y(1))/D];
end
function res =bcfcn(ya,yb) % boundary conditions
res = [ya(1)
yb(1)-L];
end
function g = guess(x) %initial guess for y and y'
g = [0 1];
end
plot(sol.C, Sol.x,'-0')
  댓글 수: 10
Naveen Krish
Naveen Krish 2022년 3월 15일
y1 = C, y2 = dc/dx, y2' = d''c/dx2 this is how the derivative should be right?
Walter Roberson
Walter Roberson 2022년 3월 15일
No. In MATLAB, ' is an operator means "complex transpose". It cannot be part of the name of a variable.
x = [1+2i 3-4i]
x =
1.0000 + 2.0000i 3.0000 - 4.0000i
x'
ans =
1.0000 - 2.0000i 3.0000 + 4.0000i
When you have numeric data, you can do numeric estimation of the derivative using gradient()
If you have the Symbolic toolbox, then you can use diff() to request symbolic differentiation
syms x
f = tan(1-x^2)
f = 
f__prime = simplify(expand(diff(f, x)))
f__prime = 
f__primeprime = simplify(diff(f__prime,x))
f__primeprime = 

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Formula Manipulation and Simplification에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by