Piecewise symbolic function with Heaviside and Dirac
조회 수: 4 (최근 30일)
이전 댓글 표시
hello!
I need help creating a piecewise function from 2 symbolic functions. Everything works well, I can form the piecewise function, and take its second derivative. But when I try to evaluate the second derivative, it gives me an error with Dirac. Here are my 2 functions:
syms x
a = x^6 + x^5;
b = x^6 + x;
f = '(heaviside(x)-heaviside(x-1))'*a + '(heaviside(x-1))'*b; %0<x<1 use function a, and x>=1 use function b
f_double_prime = diff(diff(f)); % take the second derivative of the piecewise function f
ht = matlabFunction(f_double_prime); %create a matlab function
ht(2); %evaluate the function at x = 2
The last line gives me the error: " Error using dirac. Too many input arguments. " I believe it's because the matlab function 'ht' contains terms like this '(dirac(x - 1, 1)' which gives matlab problems.
How do I correctly evaluate the function? Clearly ht(2) does not work. What is the correct syntax? Is their a better way to form a piecewise function from 2 symbolic functions?
*Please note*** I cannot first take the second derivative of each separate function first...AND THEN form the piecewise function. This is because the existing code would not work, so I have to follow their system.
thanks in advance
댓글 수: 0
답변 (2개)
Walter Roberson
2014년 4월 4일
You are attempting to multiply a string by something. As indicated earlier, that cannot work.
댓글 수: 1
참고 항목
카테고리
Help Center 및 File Exchange에서 Assumptions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!