In symbolic expression how to include an expression that is a function of the symbolic variable?
2 ビュー (過去 30 日間)
古いコメントを表示
I have an expression given as e.g.:
g = @(x) f*x
where f is a function of x and is defined as
f(x) = b if x > a
f(x) = c if x <= a
and a,b,c are constant numbers.
1. How to define this function? How can a parameter depend on the symbolic variable in a symbolic expression?
2. How can I multiply two expressions like this? What I want to get is:
g = @(x) a*x;
h = @(x) b*x;
gh = g*h; % I want to get gh = a*b*x^2;
It gives an error saying
"Undefined function 'mtimes' for input arguments of type 'function_handle'."
I also tried gh = @(f) g*h, which also doesn't work.
0 件のコメント
採用された回答
Mischa Kim
2014 年 4 月 14 日
編集済み: Mischa Kim
2014 年 4 月 14 日
László, try
g = @(x) x*(c*(x<=a) + b*(x>a));
and
gh = @(x) g(x)*h(x);
2 件のコメント
Mischa Kim
2014 年 4 月 14 日
I believe this one is similar to the other question I just answered, unless you mean something different by solve...
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!